Dim myData as String * 256
Category Lotusscript padding truncation
Bookmark :
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:
Bookmark :
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.

Comments
Posted by Lance At 12:21:01 AM On 09/04/2007 | - Website - |
Its the same as a bunch of other languages in that respect - java is another.
I tend to just use the fixed length stuff for C-API calls...
---* Bill
Posted by Wild Bill At 07:26:53 PM On 08/31/2007 | - Website - |
In the right situations, fixed-length strings rock. Most of the rest of the time, though, they're not terribly oonvenient
Posted by Bob Balaban At 05:08:15 PM On 08/31/2007 | - Website - |