DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Errror expected Then

Hello All,

I have an error with a Diadem(10.2) script that occurs only when it is called with Labview(8.2)  and only when Diadem is not previously opened.  If I open Diadem and then call the script with LabView the error never occurs. 

The Error reads reads
Error in <Field Test Script.VBS> (Line 778, column 21):
 "Expected 'Then'

This particular line is a regular If Statement and yes there is a "Then" after the "if". 



Has anybody had any similar errors?
BBANACKI
0 Kudos
Message 1 of 4
(4,056 Views)

Hi BBANACKI,

Nope, this doesn't sound familiar, so we're going to need to go fishing for clues.  First of all, that's a pretty lengthy script you're running from LabVIEW, so the key line of code may be somewhere between line 1 and line 778.  Still, how about if you post what line 778 is, just in case there's a clue there.  The DIAdem error messages are usually pretty good, so let's start where they're pointing to.

Also, let's take LabVIEW out of the equation for testing purposes.  Try running that same "Field Test Script.VBS" from an external VBScript running in the Windows VBScript host (double-click on the VBS file in Windows Explorer).  The code of the test VBScript will look something like this:

Set ToCommand = CreateObject("DIAdem.ToCommand")
ToCommand.CmdExecuteSync("ScriptStart(""C:\Field Test Script.VBS"")")
Set ToCommand = Nothing

Let me know if this VBScript-instead-of LabVIEW approach reproduces the same behavior (that is dependent on whether DIAdem was previously launched).

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 4
(4,035 Views)
Line 778 is a simple If Statement in a Function  that isn't even called  for the particular TDM file I have selected.

Line 778 =   
sub CompileSRErefDATA
.
..
... 
if refch1 = 1 then
          Call ChnAlloc("SRE REF Total Mutes"&Routenum,1024,1,DataTypeFloat64,"Numeric",RecieverIndex,channum)
          CHT(refch1,"[" & RecieverIndex & "]/SRE REF Total Mutes"&Routenum) =  CHT(1,"[" & RecieverIndex & "]/["&increment&"]")
          Call ChnAlloc("SRE REF Percent Avail"&Routenum,1024,1,DataTypeFloat64,"Numeric",RecieverIndex,channum + 1)
          CHT(refch1,"[" & RecieverIndex & "]/SRE REF Percent Avail"& Routenum) =  CHT(1,"[" & RecieverIndex & "]/["&increment+1&"]")
          SRErefDataGroup = recieverindex
         
      else
          CHT(refch1,"[" & SRErefDataGroup & "]/SRE REF Total Mutes"&Routenum) =  CHT(1,"[" & RecieverIndex & "]/["&increment&"]")
          CHT(refch1,"[" & SRErefDataGroup & "]/SRE REF Percent Avail"&Routenum) =    CHT(1,"[" & RecieverIndex & "]/["&increment +1&"]")
      end if
...
..
.
end sub

I have tried running the Script from the Windows VBScript host as you asked and I get the same error.  With further investigation I have found that not only must Diadem be open but the script must be loaded in the memory  for the scriptstart command to work.  
BBANACKI
0 Kudos
Message 3 of 4
(4,021 Views)

Hi BBANACKI,

Your last statement sounds like the hot clue I was looking for.  An automatic result of loading a VBScript into DIAdem memory is that the variable AutoDrvUser is set to the Windows folder that the VBScript came from.  Thereafter a command which references the file only without the file's full path would succeed, but prior to this the same command would fail.  Look at the VBScript snippet I sent you earlier, this is the equivalent of the difference I'm talking about:

Set ToCommand = CreateObject("DIAdem.ToCommand")
ToCommand.CmdExecuteSync("ScriptStart(""Field Test Script.VBS"")")
Set ToCommand = Nothing

Set ToCommand = CreateObject("DIAdem.ToCommand")
ToCommand.CmdExecuteSync("ScriptStart(""C:\My FieldTest Folder\Field Test Script.VBS"")")
Set ToCommand = Nothing

The top 3 commands above would behave as you suggest, while the bottom 3 commands would run correctly even if the VBScript had not been loaded into memory.

Please check and see if you are referencing any files (*.VBS, *.SUD, *.TDV, *.TDR, etc.) by filename only and let me know.  This may not be the issue, but it sure would explain the behavior you see, even though it would be at odds with the error message displayed.

Brad

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