hexagon logo

Modifying PCDMIS Array Variable with External Command

I want to build PCDMIS array variables externally using an EXE. As we all know, doing so within PCDMIS with a loop is slooowwwww. 

I can change simple String or Long value variables.  However, arrays are an issue.

PCDMIS Basic and PCDMIS Automation reference the methods GetVariableValue, SetVariableValue, GetArrayIndexValue, and SetArrayIndexValue.

The first two animals work.

The latter two (GetArrayIndexValue, and SetArrayIndexValue) do NOT seem to work. I get Server Automation errors with SetArrayIndexValue and zero values using GetArrayIndexValue.

Any thoughts? Clever ideas and insults welcome.

Thanks,

-Mike

  • This method works, but I am not entirely sure if this is what  you need. But you may be able to attempt something similar.

    This is to modify an existing array. Using input box to enter the array's variable name, and an input box to enter the new values for the array

    Sub Main()
    
        Dim DmisApp As Object
        Dim DmisCmds As Object
        Dim DmisCmd As Object
        Dim DmisPart As Object    
    
        Set DmisApp = CreateObject("PCDLRN.Application")
        Set DmisPart = DmisApp.ActivePartProgram
        Set DmisCmds = DmisPart.Commands
    
        L$ = InputBox$("Enter name of variable to be modified", "Modify Array Box","")    
        If L$ = "" Then Exit Sub
    
        Fcntr = 0
        For Each DmisCmd In DmisCmds
          If DmisCmd.Type = 195 Then 'Type 195 = ASSIGNMENT
            If DmisCmd.GetText(DEST_EXPR, 0) = L$ Then
            M$ = InputBox$("Modify Array Value", "Enter new Array", "")    
            If M$ = "" Then Exit Sub
            retval =  DmisCmd.PutText("ARRAY(" & M$ & ")", SRC_EXPR, 0)
            End If
          End If
        Next DmisCmd
        
        Set DmisCmd = Nothing
        Set DmisCmds = Nothing
        Set DmisPart = Nothing
        Set DmisApp = Nothing
    End Sub

    Creating a new array. Using input box to enter the variable's name for the new array, and an input box for the array values

    Sub Main()
    
        Dim DmisApp As Object
        Dim DmisProgram As Object
        Dim DmisCmds As Object
        Dim DmisCmd As Object
        Dim DmisPart As Object    
    
        Set DmisApp = CreateObject("PCDLRN.Application")
        Set DmisPart = DmisApp.ActivePartProgram
        Set DmisCmds = DmisPart.Commands
            
        L$ = InputBox$("Enter name variable", "New Array","")    
        If L$ = "" Then Exit Sub
        M$ = InputBox$("New variable value", "Enter Array Value", "")    
        If M$ = "" Then Exit Sub
    
        Set DmisCmd = DmisCmds.Add(ASSIGNMENT, True)
        retval = DmisCmd.PutText (L$, DEST_EXPR, 0)
        retval =  DmisCmd.PutText("ARRAY(" & M$ & ")", SRC_EXPR, 0)    
        
        Set DmisCmd = Nothing
        Set DmisCmds = Nothing
        Set DmisPart = Nothing
        Set DmisApp = Nothing
    End Sub