06-15-2009 04:34 PM
One of my user dialog boxes is made up of a table (Table1) that allows the user to provide values for data manipulation. The script bellow is associated with the "OK" button of this dialog box. It was written in DIAdem 10 and I am now trying to run the same script using DIAdem 11.1 (beta), because I want to use the new DRI (Dynamic Response Index) calculation function later in my scripts.
Sub OK_EventClick()
Dim This : Set This = OK
L2 = TABLE1.Rows.COUNT
'MULTIPLICATION
mltcorfile = datadrvuser & "chnmlt.asc"
If FILEX(mltcorfile) Then
Call FileDelete(mltcorfile, 0)
End If
mltcorfile = datadrvuser & "chnmlt.asc"
Call FILEWRITELN(mltCORFILE, 1, "MULTIPLICATION FACTORS")
For I = 1 To L2
R3 = TABLE1.Columns(2).CELLS(I).VALUE
If R3 <> 0 Then
T1 = TABLE1.Columns(1).CELLS(I).VALUE
Call FILEWRITELN(mltCORFILE, 1, "(" & I & ") " & T1 & " = " & R3)
'*****************DOES ACTUAL MULTIPLICATION OF DATA CHANNELS
L10 = I
T3 = CC(L10)
T4 = CN(L10)
T5 = CD(L10)
Call FORMULACALC("CH(L10):=CH(L10)* R3")
CC(L10) = T3
CN(L10) = T4
CD(L10) = T5
End If
Next
Call filewriteln(mltcorfile,1, "END")
'TRUNCATION
trtcorfile = datadrvuser & "chntruncate.asc"
If FILEX(trtcorfile) Then
Call FileClose(trtcorfile) 'Ben added 11-10-06 to eliminate errors deleting the trtcorfile.
Call FileDelete(trtcorfile, 0)
End If
trtcorfile = datadrvuser & "chntruncate.asc"
Call FILEWRITELN(trtcorfile, 1, "TRUNCATION FACTORS")
For I = 1 To L2
L4 = TABLE1.Columns(3).CELLS(I).VALUE
If L4 <> 0 Then
T2 = TABLE1.Columns(1).CELLS(I).VALUE
Call FILEWRITELN(trtcorfile, 1, "(" & i & ") " & T2 & " = " & L4)
End If
Next
Call filewriteln(trtcorfile,1, "END")
End Sub
The error message I receive is with R3 (in the red text above):
Cannot assign value to a floating point variable
<R3 = >
Any ideas of where this error might come from woult be appreciated. Remember that this script runs perfectly in DIAdem 10.
06-16-2009 10:08 AM
H CrshTstr,
I can't explain why you're seeing the error only in DIAdem 11.1 and not previous versions, but the error message itself is quite clear. The "R3" global variable is explicitly data typed as a Double/Real64. The error message claims that you are trying to assign to this Real64 variable a value that can not be coerced into a Real64-- for instance a string such as "abc". Try putting the following debug code in place of the current red command line:
On Error Resume Next
R3 = TABLE1.Columns(2).CELLS(I).VALUE
IF Err.Number <> 0 THEN MsgBox "I = " & I & " --> """ & TABLE1.Columns(2).CELLS(I).Value & """"
On Error Goto 0
That should highlight the problem,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
06-16-2009 10:39 AM - edited 06-16-2009 10:47 AM
Thanks for the response, Brad!
I replaced my red line with your suggested text, but I'm still receiving the same error message...and I'm not getting the msgbox that is supposed to report the value of "i". When I was working with it earlier I had set up a msgbox to output the value of "i" each time through the For Loop. What I noticed was that the first time the msgbox came up i = 1, then the second time i = 0, and then I got the error message.
The table fields that are available for user input are all being left empty. I'm not sure if this might be part of the problem as well. We did have a bit more success (the script ran slightly further), when "0" were entered in all available table fields.
***EDIT*** I guess I wasn't saving my Dialog Box before running the script. I thought it would work like scripts within DIAdem, where unsaved changes are still recognized. Below are the outputs of the msgbox:
I=1 --> "1"
I=2 --> " "
06-16-2009 12:02 PM
06-17-2009 10:07 AM
Hi CrshTstr,
I'd recommend using the function "val()" to coerce the typed text to a real number.
Brad Turpin
DIAdem Product Support Engineer
National Instruments