hexagon logo

GetVariableValue Problem

Dear guys:

about the method "GetVariableValue",the help file says like this--PC-DMIS variables only hold values during execution; at learn time PC-DMIS variables have a value of zero. The GetVariableValue and SetVariableValue methods only change a variable's value during the script's execution. If you want to permanently change a value of a variable inside PC-DMIS, you should use the PutText method instead.

when my mouse enter the parameter,it shows the result on the screen.but how can i get that value?(offline software,but the program has been run before)



string ReturnValue="";
Variable tmpVarValue;
pcdPartProgram = pcdSession.ActivePartProgram;
tmpVarValue = pcdPartProgram.GetVariableValue(VarName);
if (tmpVarValue.VariableType == VARIABLE_TYPE_TYPES.VARIABLE_TYPE_STRING)
{
ReturnValue = tmpVarValue.StringValue;
}
else if (tmpVarValue.VariableType == VARIABLE_TYPE_TYPES.VARIABLE_TYPE_DOUBLE)
{
ReturnValue = tmpVarValue.DoubleValue.ToString("F3");
}
else if (tmpVarValue.VariableType == VARIABLE_TYPE_TYPES.VARIABLE_TYPE_LONG)
{
ReturnValue = tmpVarValue.LongValue.ToString("F3");
}

then i get 0.000,whie the shown result is -0.071.and i wanna get the value -0.071



Parents
  • I use GetText for retrieving variable values, snippet from my program logger (full source somewhere in this forum):

    'Assignment To look For
    varname = "WATCHER"
    ' Is it enabled?
    sstate = ""
    
    For cnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(cnt)
    If ((PCDCommand.Type = 195) And (varname = PCDCommand.GetText(DEST_EXPR, 0))) Then
    wvar = [B]PCDCommand.GetText(SRC_EXPR, 0)[/B]
    
    If wvar = """""" Then
    sstate = " started @ "
    retval = PCDCommand.PutText("""TRUE""", SRC_EXPR, 0)
    End If
    If wvar = """TRUE""" Then
    sstate = " ended @ "
    retval = PCDCommand.PutText("""""", SRC_EXPR, 0)
    End If


    The code is looking for a variable (assignment) called "WATCHER", when this is found and the contents of the variable is null we set it to "TRUE". Is it already "TRUE" then we clear it (empty). Note that this actually changes the assignment command in the program.


    thank you .i tried this method,then i got "OBTAIN("FA(N0001)",5,0)",or other expressions(such as "ABS(A-B)")
  • That is because the value of UZZ really is "OBTAIN("FA(N0001)",5,0)"... It seems you are trying to call a function and have the result of that function put in UZZ?

    Is OBTAIN a PC-DMIS function?
Reply Children
No Data