NI Home > Community > NI Discussion Forums

DIAdem

Reply
Member
adek
Posts: 44
0 Kudos

VBScript continue on new line syntax

Hello there,

As I'm a DIAdem script beginner, I've created a script using the recorder mode, but need to add additional channels to be subracted and to avoid the line becoming to long, want to continue the command on the next line.

Can't seem to find anything referring to multiline syntax in the DIAdem script help - searched the web and found that normal vbscript uses '&_ ' but doesn't seem to work.

Anybody help ?

Regards

AdeK

Active Participant
Twigeater
Posts: 649
0 Kudos

Re: VBScript continue on new line syntax

Hello AdeK!

 

Just the _ does the job. The &_ is used if you have a long string and want concat it on multiple lines. No different syntax! & for the string concat _ for the new line!

 

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
Member
adek
Posts: 44
0 Kudos

Re: VBScript continue on new line syntax

Hi Matthias,

Tried it and get the warning 'unterminated string constant' after I try running the code, the script screen shows a red squiggle after the _ character in the line code.

Must be doing something else wrong, but note I have to add another 120 channels to this sum ! (I realise there will be a much easier way using some sort of FOR NEXT loop), but I'm just a beginner !

 

here's the code

ChnCalculate("Ch(""Load Comparison"")=Ch(""Alt Amps"")-(Ch(""Main A"")_

+ch(""Starter A"")+Ch(""DF_1_FUEL_SENS1""))") '... FormulaTxt

 

Regards

 

Adrian

Active Participant
Twigeater
Posts: 649
0 Kudos

Re: VBScript continue on new line syntax

Hello AdeK!

 

You want to spread a string on multiple line than you have to close the string, add a closing ", add a & to concat the two strings and a starting " in the new line.

 

ChnCalculate("Ch(""Load Comparison"")=Ch(""Alt Amps"")-(Ch(""Main A"")" & _

"+ch(""Starter A"")+Ch(""DF_1_FUEL_SENS1""))") '... FormulaTxt



Conclusion: You have to split the string into two parts, concat them and then you can use the _ to put them on two lines.

 

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?