DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

VBScript

Hi,

 

i am currently working with NI DIAdem tool, using VBScript.

 

i want to parse the content inside the text file to the Data Base using  DIAdem TDM. 

 

i want  to create one variable as a global variable and use that variable thoughtout my script, i declared my variable using Public but it is not working, please guide me how do i create and use global variable in VBScript

 

thanks,

kalpana

 

0 Kudos
Message 1 of 4
(4,342 Views)

Hi kalpana,

 

You'll have to be more clear with your first question.

 

The answer to your second question is to use the "GlobalDim" command.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(4,319 Views)
Hi, thanks for your reply. still i am facing problem. my full program is pretty large. so i tried to short and gave below, Do While ( File.Position < File.Size ) 'Read Text Line by line sLine = File.GetNextLine sTime = Right ( File.Info.FileName, 4 ) hh = left (sTime,2) mm = right (sTime,2) sTime = "TIME :" &" " & hh & ":" & mm Count1 = charCount ( sLine,sTime ) if Count1 = 1 then st = Split ( sLine, "TIME :", 3, vbTextCompare) pair.Add CleanString (Trim (st(0))), CleanString (Trim (st(1))) sWord = "Time:" & st(1) sDate = Right(st(0),16) st = Split ( sWord, ":", 2, vbTextCompare) sTime1 = st(1) pair.Add CleanString (Trim (st(0))), CleanString (Trim ( st (1))) Root.Properties.Add "Time", pair.Item ( "Time" ) sWord = "Date:" & sDate st = Split ( sWord, ":", 2, vbTextCompare) pair.Add CleanString (Trim (st(0))), CleanString (Trim ( st (1))) Root.Properties.Add "Date", pair.Item ( "Date" ) sTimeValue = sDate & sTime1 GlobalDim ("sTimeValue") Set sTimeValue = File.Formatter.ParseString(sTimeValue ,etime) Call Root.Properties.Add( "DateTime", sTimeValue ) end if Count4 = charCount ( sLine,"SERIAL-NUMBER :" ) if Count4 =1 then oChannel.Properties.Add "DateTime", sTimeValue ) end if end if Loop when i try to call sTimeValue in the second if condition, it is giving error saying type mismatch. i am sure i am missing something. but i don't know what. pls help me.
0 Kudos
Message 3 of 4
(4,282 Views)

Hi kalpana,

 

You didn't mention you were creating a DataPlugin.  You can only use the GlobalDim command in a DIAdem VBScript or SUDialog.  This command is not available (or necessary) in a VBScript DataPlugin.  You can make any variable global simply with the Dim statement, as long as you declare the variable above the Sub ReadStore().

 

As best I can figure from your run-on posted code above, this is the line you say you get the "type mismatch" error from, is that correct? 

oChannel.Properties.Add "DateTime", sTimeValue

I'm wondering where this oChannel variable comes from.  If you try to assign a string variable value to a datetime property (or vice-versa) you will get an error like this.  How often does the oChannel variable change-- every line, or less often?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 4
(4,268 Views)