hexagon logo

Basic script error in PC-DMIS

Any help would be appreciated here. I keep getting an error message that pops up when trying to run a basic script. I've used this same script for months now, and never had any issues. now all of the sudden on 1 machine, I am getting this error. I see nothing wrong with the code in the script, and it hasn't been changed at all. I'm thinking that this might be an error on PC-DMIS side of things, and not actually an error with the script.... only problem is idk what to do to fix it...

here is the script, if any one could double check this. original script was pulled from a post here, I think by

'Script for saving PC-DMIS reports by serial number in Work Order folder
'Will create folder for work order if none is present

'SETTINGS FOR USE
'Program should have 2 comments and ASSIGN variables created for the inputs of those comments as shown below
'C1         =COMMENT/INPUT,YES,FULL SCREEN=NO,
'            WORK ORDER
'C2         =COMMENT/INPUT,YES,FULL SCREEN=NO,
'            SERIAL NUMBER
'            ASSIGN/WO=C1.INPUT
'            ASSIGN/SN=C2.INPUT

'At the end of program create another ASSIGN variable labeled REPORT_PATH and its value should be the file location you want reports in, minus the work order folder
'and with the "+WO+" variable at the end
'Example of assignment - ASSIGN/REPORT_PATH="F:\QUALITY\CMM\CMM inspection reports\BOEING\314A6128-21\\"+WO+"

'After this line enable the script to run in the program, and mark script code lines

'Now ASSIGN variable labled VAR_FILENAME and its value should have the same path as above but with the addition of SN variable and .PDF to enable the report to save
'Example of this assignment - ASSIGN/VAR_FILENAME="F:\QUALITY\CMM\CMM inspection reports\BOEING\314A6128-21\\"+WO+"\\"+SN+".PDF"

'After this, in the edit window, hit ENTER then type "PRINT" then hit TAB, and place cursor in the new code and hit F9, click the report output checkbox
'And in the text box below type VAR_FILENAME
'Then click the "Overwrite" option, "PDF" option, and select any other options you see fit

'Auto archive of reports is now set up and ready to run

'Notes for use written by ANDY SMITH, script pulled from PC-DMIS Forum, and edited for use by ANDY SMITH, original script by DaVe_M

Sub Main()

Dim objFSO, objShell
Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
Dim objFile, objFolder As Object

Set PCDApp=CreateObject("PCDLRN.Application")
Set PCDPartProgram=PCDApp.ActivePartProgram
Set PCDCommands=PCDPartProgram.Commands

Set Pathname=PCDPartProgram.GetVariableValue("REPORT_PATH")

strPath=Pathname.StringValue

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(strPath) Then
  'Nothing
Else
  Set objFile=objFSO.CreateFolder(strPath)
End If

End Sub​

Attached Files
Parents
  • Does this happen with all programs on that one machine? Or just certain programs? Have you ran this in the vbs editor inside pc dmis so you can see what line the failure is on for troubleshooting?
    Your error says line 49 error, which is the line that creates the folder. If all other lines succeeded, my guess would be a special character was used in the operator input and the script cannot create the folder because windows does not allow special characters in files names. If using operator inputs for creating directories, I highly recommend using some code to check for special characters and looping back to the operator input if found.
    Just a guess.
  • I found out pretty quickly that if I allow anyone to enter an input, and that input is used to create files for windows, that it will eventually break because someone wants to write "N/A" into a field.
    You can search for special characters inside of pc dmis by using if/ and goto commands.

    Redo =Label
    If/index(c1.input,"//")==0 or index(c1.input,"?")==0 or index(c1.input,"*")==0 etc
    Comment/oper
    Please retype without using special characters.
    Goto/Redo/
    End_if/

    I have since switched to a custom form inside of pc dmis while using VB scripts to ensure special characters aren't used. Reduces the code inside of pc dmis and won't even allow you to enter the character.
Reply
  • I found out pretty quickly that if I allow anyone to enter an input, and that input is used to create files for windows, that it will eventually break because someone wants to write "N/A" into a field.
    You can search for special characters inside of pc dmis by using if/ and goto commands.

    Redo =Label
    If/index(c1.input,"//")==0 or index(c1.input,"?")==0 or index(c1.input,"*")==0 etc
    Comment/oper
    Please retype without using special characters.
    Goto/Redo/
    End_if/

    I have since switched to a custom form inside of pc dmis while using VB scripts to ensure special characters aren't used. Reduces the code inside of pc dmis and won't even allow you to enter the character.
Children
No Data