« Lotus Open Labs in Dallas and Houston starting next week | Main| Early Mac Notes 8.5 beta download appears to be a Solaris server install »

Dim myData as String * 256

Category
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 

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

Gravatar Image1 - Thanks! I am sure this will be of good help for me and not only Emoticon

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

RSS

Powered By

Domino BlogSphere
Version 3.0.1 Beta 7