hexagon logo

Expression information pulling with VB Script

Hello all,

Some little things I was curious about. Can't really figure our the syntax of.


Sub[SIZE=2][COLOR=#000000] Main[/COLOR]
[/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]'PCDMIS COMMANDS assignment
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] App, Part, Cmds, Cmd [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] App = CreateObject("PCDLRN.Application")[/COLOR]

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Part = App.ActivePartProgram[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmds = Part.Commands[/COLOR]
[/SIZE]


Start of my script. From there I go into this.


For[SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmd [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmds[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmd.[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] = ASSIGNMENT [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.GetText(DEST_EXPR, 0) = "CMMPROGRAM" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]blr= Cmd.GetText( SRC_EXPR, 0)
bll= Len(blr)
Prognam=Mid(blr,2,bll-2) 
Cmd.ReDraw
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
End If
[/COLOR][/SIZE][/COLOR][/SIZE]


I use the above function to pull in Variables I have hardcoded in the program and use to display in a form later on in the script. It currently works great.

However if I change the format of the variable it starts to get screwy.

Currently I have the Variables laid out as.

$$ NO,====================================================
     ,PART INFORMATION:
     ,CMMPROGRAM=Part # & what is being checked
     ,PRINTNUM=Print #
     ,PRINTREV=Print Rev.
     ,PARTNAM=Part Name
     ,PARTNUM=Is Part # used in-house, may be the same as Print #
     ,====================================================
            ASSIGN/CMMPROGRAM="A Nut Op 1"
            ASSIGN/PRINTNUM="534543"
            ASSIGN/PRINTREV="A"
            ASSIGN/PRINTREV1=PRINTNUM+", Rev. "+PRINTREV
            ASSIGN/PARTNAM="54w643653"
            ASSIGN/PARTNUM="4356363ty3y"


If i change the variables to inlcude a Variable or alter the layout in anyway, the string doesn't compute properly.

I found a vb function for "GetRightSideOfExpression" in the help section. How would i go about implementing it?

Does someone have a better method of pulling in a Variable value?

Version 4.3.
  • Do you want to rename the program?
    I'm form China.
  • I just implemented it this way.

    Variables
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Prognam1 = PCDPartProgram.GetVariableValue ("CMMPROGRAM")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Printnam1 = PCDPartProgram.GetVariableValue ("PRINTREV1") [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Partnam1 = PCDPartProgram.GetVariableValue ("PARTNAM")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Partnum1 = PCDPartProgram.GetVariableValue ("PARTNUM")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Operat = PCDPartProgram.GetVariableValue ("OPERATOR")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Job = PCDPartProgram.GetVariableValue ("JOB")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Samp = PCDPartProgram.GetVariableValue ("SAMP")
    
    [/COLOR]
    Prognam = Prognam1.StringValue
    Printnam = Printnam1.StringValue
    Partnam = Partnam1.StringValue
    Partnum = Partnum1.StringValue
    Opera = Operat.StringValue
    Jo = Job.StringValue
    Sam = Samp.StringValue
    [/SIZE]
    


    I did try GetExpression vpt.se, it just kept giving me a blank text box. I have used getvariablevalue before and didn't think about it in the application. At first it perplexed me as it always showed blank during a test execution and then I remembered it only populates during an actual execution.

    So problem solved. Thank you.