Dim myData as String * 256

You C-coders have known about this for years I’m sure. Many of you Lotusscript types probably have known about this for years. Hell, once upon a time, I probably knew this. But yesterday, I ran across a line of code like this and was intrigued… “What the heck is that?”

If you peruse help for the String data type, you find:

The declaration of a string variable uses this syntax:

Dim varName As String [* num]

The optional num argument specifies that varName is a fixed-length string variable of num characters. A fixed-length string variable is initialized to a string of null characters (the character Chr(0)).

When you assign a string to a fixed-length string variable, LotusScript truncates a longer string to fit into the declared length. It pads a shorter string to the declared length with trailing spaces.

Fixed-length strings are often used in declaring data structures for use in file I/O or C access.

I don’t know about you, but I don’t know how many times I’ve written some kind of padding function so that my data was exactly the length I needed, whether for some kind of data export, or funky display table thing.

Oh well, old dogs can learn new tricks.

3 thoughts on “Dim myData as String * 256

  1. I just like the valuable info you provide in your articles. I will bookmark your weblog and check once more here frequently. I am moderately sure I will be told lots of new stuff right right here! Best of luck for the following! kccefeaddakf

  2. This kind of game gives a real experience of building a farm and planting trees. ekbkeedfdcgd

Comments are closed.