ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace All in DIAdem Script

Solved!
Go to solution

Hi,

 

I have multiple scripts that do certain jobs. In each of them, all I want to do is change some channel names. I can change each channel name individually by hitting Ctrl + F to bring up the Find and Replace dialog box and selecting Replace With - Replace All. Does anyone know if I can manually do the same functions as Ctrl + F function from the script editor? 

 

Thanks

 

0 Kudos
Message 1 of 5
(5,478 Views)
Solution
Accepted by topic author Kevster

Hi Kevster,

 

I would have said that using <Ctrl-F> from the keyboard IS manual script editing.  But it sounds like what you should be doing instead is using some channel name variables instead of channel name string constants.  Then you would have one location in your script (usually at the top) where each channel name string is assigned to its channel name variable-- this one short spot in your script will be super easy to edit.  The rest of your code will just use the channel name variables instead of string constants and will never need to be changed.

 

Brad Turpin

DIadem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(5,468 Views)

Thats it, why didn't I think of that!

 

Thanks for the idea!

0 Kudos
Message 3 of 5
(5,453 Views)

Hi Brad,

 

I am trying to use the variable as you suggested but I cant seem to get it, maybe you could help me. I am trying to use do a set of equations through this method. here is what I have at the minute:

 

sFormula = "Ch(""Instrumentation/Channel2"")=Ch(""Instrumentation/Channel2"")-x+y"
aSymbol(1) = "x"
aValues(1) = CHDx(1,CNo("Instrumentation/Channel2"))
aSymbol(2) = "y"
aValues(2) = CHDx(1,CNo("Instrumentation/Channel1"))
Call Calculate (sFormula, aSymbol, aValues, "ºC")

 

 

Using a variable channel name, I think it should be something like:

 

Dim x01, x02

x01="Desired Name 1"

x02="Desired Name 2"

sFormula = "Ch(""Instrumentation/"x02""")=Ch(""Instrumentation/"x02""")-x+y" 

aSymbol(1) = "x"
aValues(1) = CHDx(1,CNo("Instrumentation/"x02""))
aSymbol(2) = "y"
aValues(2) = CHDx(1,CNo("Instrumentation/"x01""))
Call Calculate (sFormula, aSymbol, aValues, "ºC")

 

 

However, I get an error message saying "Expected end of statement" after colum 35 (which is between the first 'x' and the '02'). Do you perhaps know why this would be?

 

Regards

 

Kev

0 Kudos
Message 4 of 5
(5,445 Views)

Hi Kev,

 

You were close, you just needed to use the "&" operator in VBScript to concatenate string constants and string variables, like this:

x01="Desired Name 1"
x02="Desired Name 2"
sFormula = "Ch(""Instrumentation/" & x02 & """)=Ch(""Instrumentation/" & x02 & """)-x+y" 
MsgBox sFormula

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 5
(5,422 Views)