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 tadd pickens At 07:03:13 AM On 06/09/2010 | - Website - |