hexagon logo

Help: Puttext method Problem

Hi,

Since our operators dont seem to be able to enter SNs correctly, I'm trying to program a dropdown menu fed with a textfile that contains all the SNs.
The Dropdown is made in Basic and reads out everything in the textfile...
So far so good...
When I try to transfer the data to PCDMIS, it doesnt work anymore (most probably because I'm doing something wrong)...


This is my code inside PCDMIS:

ZUWEISEN/DROP_SEL=""
CS1 =SKRIPT/DATEINAME= U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\DROPDOWN HYPERDYNAMIC (FROM FILE).BAS
FUNKTION/Main,EINBLENDEN=JA,,
STARTSKRIPT/
ZUWEISEN/DROP_SEL=0
ENDESKRIPT/
KOMMENTAR/PROT,
"" + DROP_SEL​



Dim PCDDmisApp As Object
Dim PCDDmisPart As Object
Dim PCDDmisCommands As Object
Dim PCDDmisCommand As Object
Dim DROP_SEL As String

Sub Main ()



Set PCDDmisApp = CreateObject("PCDLRN.Application")
Set PCDDmisPart = PCDDmisApp.ActivePartProgram
Set PCDDmisCommands = PCDDmisPart.Commands

Dim Command As Object

Let Count = "1"
Open "U:\Laurent Despineux\PC DMIS\Automated\Superdynamic\list.txt" For Input As #1
Do While Not EOF(1)
       Line Input #1, Textline
       Count = Count + 1
Loop
Close #1

Dim MyList$ (25)

Let C= "0"
Open "U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\list.txt" For Input As #1
Do While Not EOF(1)
       Line Input #1, Textline
               MyList(C) = LEFT(Textline, 10)
       C = C + 1
Loop
Close #1

Begin Dialog DialogName1 200,184, "Part Number Selection Dialog Box"
Text 10,10,88,22, "N auswählen:"
DropListBox 42,76,108,186, MyList$(), .DropList1$
CancelButton 42,108,40,12
OKButton 90,108,40,12
End Dialog


Dim Dlg1 As DialogName1

'       Dlg1.DropList1  =  0 this shows item (0) default In the window In the drop down list
'       You can change it To show Any item On top from Mylist()
Dlg1.DropList1  =  0

'       If cancel button is selected, Exit Sub
Button = Dialog(Dlg1)
If Button = 0 Then Exit Sub
  
Vari = Dlg1.DropList1
Set PCDDmisCommand = PCDDmisCommands.Add(ASSIGNMENT,True)
PCDDmisCommand.Marked = True
retval = PCDDmisCommand.PutText("DROP_SEL",DEST_EXPR,0)
retval = PCDDmisCommand.PutText(mylist$(Vari),SRC_EXPR,0)
MsgBox mylist$(Vari)
End Sub

​


If i'm putting a Value manually (for instance "12345") instead of the variable (mylist$(Vari)) then it's working...
Additional information: the "ZUWEISEN/DROP_SEL=0" contains the Value chosen in the dropbox when the script is finished... unluckily I cannot use it since when i check it's content with a usercomment, it is "0"
Any ideas?

Parents
  • Good day,

    your problem can be solved relatively easily:​


    you define a DropListBox called "DropList1$"
    DropListBox 42,76,108,186, MyList$(), .DropList1$

    but call for "Vari = Dlg1.DropList1"

    If you don't have "Option Explicit" at the beginning, it creates the objects and variables automatically and you don't get an error message, but you quickly overlook a typo


    at least that's how it works for me
    (Caution, I did not test the file reading)
    (why are you opening the file twice?)​

    Option Explicit
    
    Sub Main()
      ' Dim something -----
        Dim PCDDmisApp As Object
        Dim PCDDmisPart As Object
        Dim PCDDmisCommands As Object
        Dim PCDDmisCommand As Object
        Dim DROP_SEL As String
        Set PCDDmisApp = CreateObject("PCDLRN.Application")
        Set PCDDmisPart = PCDDmisApp.ActivePartProgram
        Set PCDDmisCommands = PCDDmisPart.Commands
        Dim Command As Object
        
        Dim vSNRList(25) As String
        Dim vSNRLine As String
        Dim vSNRCount As Integer
        Dim vButton As Integer
        Dim retval
    
      ' count something ?
        'Let count = "1"
        'Open "U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\list.txt" For Input As #1
        'Do While Not EOF(1)
        '   Line Input #1, Textline
        '   count = count + 1
        'Loop
        'Close #1
    
    
      ' Get list
        'Let C = "0"
        'vSNRCount = 0
        'Open "U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\list.txt" For Input As #1
        'Do While Not EOF(1)
        '  Line Input #1, vSNRLine
        '  vSNRList(vSNRCount) = Left(vSNRLine, 10)
        '  vSNRCount = vSNRCount + 1
        'Loop
        'Close #1
        vSNRList(0) = "test0"
        vSNRList(1) = "test1"
        vSNRList(2) = "test2"
    
    
      ' Dim Dialog
        Begin Dialog DialogName1 200,184, "Part Number Selection Dialog Box"
          Text 10, 10, 88, 22, "N auswählen:"
          DropListBox 42, 76, 108, 186, vSNRList(), .DropList1
          CancelButton 42, 108, 40, 12
          OKButton 90, 108, 40, 12
        End Dialog
        Dim Dlg1 As DialogName1
        
      ' start Dialog
        Dlg1.DropList1 = vSNRList(0)
        vButton = Dialog(Dlg1)
        
        If vButton = 0 Then Exit Sub
        
        Set PCDDmisCommand = PCDDmisCommands.Add(ASSIGNMENT, True)
        PCDDmisCommand.Marked = True
        retVal = PCDDmisCommand.PutText("DROP_SEL", DEST_EXPR, 0)
        retVal = PCDDmisCommand.PutText(vSNRList(Dlg1.DropList1), SRC_EXPR, 0)
        
        'MsgBox MyList$(Vari)
        'MsgBox vSNRList(Dlg1.DropList1)
    End Sub​
    
Reply
  • Good day,

    your problem can be solved relatively easily:​


    you define a DropListBox called "DropList1$"
    DropListBox 42,76,108,186, MyList$(), .DropList1$

    but call for "Vari = Dlg1.DropList1"

    If you don't have "Option Explicit" at the beginning, it creates the objects and variables automatically and you don't get an error message, but you quickly overlook a typo


    at least that's how it works for me
    (Caution, I did not test the file reading)
    (why are you opening the file twice?)​

    Option Explicit
    
    Sub Main()
      ' Dim something -----
        Dim PCDDmisApp As Object
        Dim PCDDmisPart As Object
        Dim PCDDmisCommands As Object
        Dim PCDDmisCommand As Object
        Dim DROP_SEL As String
        Set PCDDmisApp = CreateObject("PCDLRN.Application")
        Set PCDDmisPart = PCDDmisApp.ActivePartProgram
        Set PCDDmisCommands = PCDDmisPart.Commands
        Dim Command As Object
        
        Dim vSNRList(25) As String
        Dim vSNRLine As String
        Dim vSNRCount As Integer
        Dim vButton As Integer
        Dim retval
    
      ' count something ?
        'Let count = "1"
        'Open "U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\list.txt" For Input As #1
        'Do While Not EOF(1)
        '   Line Input #1, Textline
        '   count = count + 1
        'Loop
        'Close #1
    
    
      ' Get list
        'Let C = "0"
        'vSNRCount = 0
        'Open "U:\LAURENT DESPINEUX\PC DMIS\AUTOMATED\SUPERDYNAMIC\list.txt" For Input As #1
        'Do While Not EOF(1)
        '  Line Input #1, vSNRLine
        '  vSNRList(vSNRCount) = Left(vSNRLine, 10)
        '  vSNRCount = vSNRCount + 1
        'Loop
        'Close #1
        vSNRList(0) = "test0"
        vSNRList(1) = "test1"
        vSNRList(2) = "test2"
    
    
      ' Dim Dialog
        Begin Dialog DialogName1 200,184, "Part Number Selection Dialog Box"
          Text 10, 10, 88, 22, "N auswählen:"
          DropListBox 42, 76, 108, 186, vSNRList(), .DropList1
          CancelButton 42, 108, 40, 12
          OKButton 90, 108, 40, 12
        End Dialog
        Dim Dlg1 As DialogName1
        
      ' start Dialog
        Dlg1.DropList1 = vSNRList(0)
        vButton = Dialog(Dlg1)
        
        If vButton = 0 Then Exit Sub
        
        Set PCDDmisCommand = PCDDmisCommands.Add(ASSIGNMENT, True)
        PCDDmisCommand.Marked = True
        retVal = PCDDmisCommand.PutText("DROP_SEL", DEST_EXPR, 0)
        retVal = PCDDmisCommand.PutText(vSNRList(Dlg1.DropList1), SRC_EXPR, 0)
        
        'MsgBox MyList$(Vari)
        'MsgBox vSNRList(Dlg1.DropList1)
    End Sub​
    
Children