UDT eof error

I'm getting an error stating "Error 20 Syntax Error.  Program: SY_Commonui.pvc" when I loop through a UDT using a button script.  Perhaps I have a typo or other mistake here.  It appears to be crashing on the eof check (highlighted in green).  Any ideas where I've goofed?

Thanks!

oUDT = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_Phantom_Kits")

if oUDT = 0 then 'run if user has permission to access UDT (oUDT would be zero if insufficient permissions)

else 'continue if user has permissions

Set oUDT = oScript.AsObject(oUDT)

retVal = oUDT.SetBrowseFilter(sPhantom) 

retval = oUDT.MoveFirst() 'start looping through ALL UDT records to search for this phantom item

Do While Not(CBool(oUDT.EOF)) 'appears to error here

retval = oUDT.GetValue("UDF_Phantom_Kit$", sPhantomCheck)
if retval = 0 then
retval = oSession.AsObject(oSession.UI).MessageBox("Error reading UDF_Phantom_Kit from SO_UDT_Phantom_Kits" & vbcrlf & oUDT.LastErrorMsg)
end if

'retVal = oSession.AsObject(oSession.UI).MessageBox("Phantom Kit: " & sPhantom & vbcrlf & "Phantom Check: " & sPhantomCheck)


retval = oUDT.MoveNext()

oScript.LinesAdded = -1


Loop

Parents
  • It appears my problem was this line: oScript.LinesAdded = -1 .  It needed to be retval = oScript.LinesAdded = -1.  Unfortunately, it's not refreshing the lines in version 2020 and the lines don't appear to be added unless I move to another tab and return to the Lines tab.  I'm going to keep working on this.  I may make a separate post for that error.

  • in reply to n0tgunshy2

    FYI, LinesAdded is a property of the oScript object, your "fix" isn't really a fix, you are merely assigning the the result of comparing the LinesAdded property to -1 to the retval variable.  When you get an error is a button script and it gives you a line number, that line number is not the line number in your script file, you have to look at the additional info and scroll through when it displays the contents of your script with all of the MAS_SCR_* variables prepended to the beginning to find the line the message referred to.

    Once you evaluate the error info again, can you confirm which line is really causing the error?

Reply
  • in reply to n0tgunshy2

    FYI, LinesAdded is a property of the oScript object, your "fix" isn't really a fix, you are merely assigning the the result of comparing the LinesAdded property to -1 to the retval variable.  When you get an error is a button script and it gives you a line number, that line number is not the line number in your script file, you have to look at the additional info and scroll through when it displays the contents of your script with all of the MAS_SCR_* variables prepended to the beginning to find the line the message referred to.

    Once you evaluate the error info again, can you confirm which line is really causing the error?

Children
  • in reply to David Speck

    Also, i just realized something else, try specifying the grid name to refresh by using the oScript.LoadGrid method, it requires you pass it the control name of the grid to load, such as "GD_Lines", which it usually defaults to if IIRC, however, i have seen cases where it caused an error when "GD_Lines" is not a valid grid control name for the current task where the button script resides.

  • in reply to David Speck

    I used your recommendation in the separate post regarding the refreshing of the grid and I no longer have this error. I'm all set!  Thank you!

    So this is what worked for refreshing:

    If InStr(UCase(oUIObj.GetFolderName()), UCase("pLines")) <> 0 Then
    fldr = 0 : oUIObj.GetValue "fldr", fldr
    If fldr <> 0 Then
    Set fldr = oSession.AsObject(fldr)
    fldr.Redraw
    Set fldr = Nothing
    End If
    End If

  • in reply to David Speck

    And I am aware of how the button script error line won't match the actual error line.  I was using messagebox to display where along in the script I was getting the error and it seemed to clearly point to oScript.LinesAdded = -1.  

  • in reply to n0tgunshy2

    I would still stick to checking the line number reported by the sage error message vs your own method just to make sure you are on the same page.