Your Products have been synced, click here to refresh
' Takes definitions from a textfile and adds these as ASSIGNMENT ' commands in the activepartprogram. ' ' The format of the definitions in the textfile: ' ' <VARIABLE_NAME>$<VARIABLE_VALUE> ' ' Ex. ' ' V1$"this is a string" ' V2$123.456 ' V3$CIR1.X ' MY_VAR$"my variable" ' ' ' (c) vpt.se 2009-27-08 ' sub Main Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDApp.ActivePartProgram Set PCDCommands = PCDPartProgram.Commands Dim CMDline, CMDvar, CMDval, CMDfile, delimpos, LineCnt ' the cmds.txt must reside in the activepartprograms folder! CMDfile = PCDApp.ActivePartProgram.Path & "cmds.txt" ' a linecounter for navigation in the cmds.txt file (if errors occurs) LineCnt = 0 Open CMDfile for input as #1 do while not EOF(1) line input #1, CMDline LineCnt = LineCnt + 1 ' we have read a line, increment the counter delimpos = instr(1, CMDline, "$") ' find the delimiter if delimpos then ' delimiter found CMDvar = left(CMDline, delimpos - 1) ' get text left of delimiter CMDval = right(CMDline, len(CMDline) - delimpos) ' get text right of delimiter CMDval = left(CMDval, len(CMDval)-1) ' get rid of the carriage return at the end set PCDCommand = PCDCommands.Add(195, True) ' add an assignment command to the program retval = PCDCommand.PutText(CMDvar, DEST_EXPR, 0) ' set the variable name retval = PCDCommand.PutText(CMDval, SRC_EXPR, 0) ' set the variable value PCDCommand.ReDraw PCDPartProgram.Refresh else MsgBox "Delimiter not found!" & Chr(13) & "Stopped at line " & LineCnt & "." ' what line lacks the delimiter? Exit do ' don't loop through the entire file if delimiter not found end if loop close #1 end sub
ASSIGN/OPERATION=0 FPTR =FILE/OPEN,"c:\temp\opnr.txt",READ V1 =FILE/READLINE,FPTR,{OPERATION} FILE/CLOSE,FPTR,KEEP COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO, OPERATION
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |