Hi David,
 
I believe the answer is simple here: you can use the underline to break any
instruction at all in the middle, so you can continue it on the next line.
 
the only place you can't break is in the middle of a quoted string, but
after one of the commas should work fine.
 
 
hth,
 
Chip
 

  _____  

From: David [mailto:[email protected]] 
Sent: Saturday, December 19, 2009 8:59 PM
To: Scripting List WE
Subject: Array definition exceeds line length in Notepad - any solution?


Scripters, you have been great help!
This time, though, I wonder if I got a tough one. Before going into details
on my problem, I want to just give a short note. For one reason, to make my
point more clear, and for another, because maybe not all on the list is
aware of this little turn-around.
 
If you have a message box (MsgBox) that needs to pressent more text, than
what can be read on one line, you have the option in a VBScript to 'split'
the instruction into several lines. That is,  instead of writeing a line in
your script like:
    
    MsgBox( "message 1" & VbCrLf & "Message 2" & VbCrLf & "Message 3" )
 
You can increase the readability of the script - without changing its
performance - by the folowing lines:
 
    MsgBox( "Message 1 " & VbCrLf &_
        "Message 2" & VbCrLf &_
        "Message 3" )
Abit more easy to maintain the script, this way, ain't it? (btw, VbCrLf is a
predefined 'CarriageReturn/LineFeed' insruction, that I just happened to
come accross the knowledge of, the other day. Saved me a lot of instructions
like Chr(10) & Chr(13) - hope it helps others as well.)
 
 
OK, now over to my challenging problem. I am using Notepad for editing my
scripts. 1. I am familiar with that editor, 2. Use it all the time, and 3. a
handful other reasons. 
 
In my scripting project, I decided to put some of the messages it use to
inform the user of its activity, into an array. A couple of good reasons for
doing so. First of all, you can easily access the same message, several
places in the script - without rewriting it everytime. Another good reason
is, that you easily can combine the different messages in the order/amount
you want. And, since I have the idea of making my script accessible in more
than one language, it is easy to edit the messages, for translation, since
they are all gathered in one place.
 
The result is, that my script would look like this:
 
'Snip code starts here:
Dim Infolines
 
Infolines = Array( "Welcome to", "my script", "You are now at the
beginning", "you are now at the end", "goodbye" )
 
MsgBox( Infolines(1) & VbCrLf &_
    Infolines(2) & VbCrLf &_
    Infolines(3) )
 
MsgBox( Infolines(2) & VbCrLf &_
    Infolines(4) & VbCrLf &_
    Infolines(5) )
'Snip ends here
 
You get the idea? Two screens will be displayed:
 
1. Welcome to
    my script
    you are at the beginning
 
2. My script
    This is the end
    goodbye
 
The challenging problem, that I ran into yesterday, and have found no work
around to, is that my Infolines array has got the length, that it doesn't
fit into one long line in Notepad. Hence, notepad makes the definition
section in my script look like:
 
dim Infolines
 
Infolines = Array( "Message 1", "Message 2", Message3", "Message
4", Message 5" )
 
And, of course, when trying to run the script, it complains about the last
line above, as it appears 'without a definition'. 
 
My question is, does there exist a way to 'split' an array definition into
several lines? Something like the &_ instruction used in MsbBox calls and
the like? That way, I could have got my array definition to work. Notepad
complaint when the total line length got just under 600 characters. I have
40 entries in the array, so you see, the 600 characters run fast... :)
 
 
Sorry for a long message, but if there would happen to be noe solution to my
problem, I still hope it gave a bit of ideas to other scripters. At least, I
have found great help in studying the 'snip codes' listers are including in
their messages. 
 
Thanks for all feedback and workarounds, you can come up with.

Reply via email to