AnsweredAssumed Answered

How to get the number of list items from a listbox in a macro

Question asked by jgardner on Apr 3, 2015
Latest reply on Apr 10, 2015 by jgardner

Hi,

 

I'm using PADS Layout 9.4.1, and I'm trying to figure out how to write a macro/script that will open the CAM dialog box, select all the items in the listbox, and then click run.  If I always knew how many items would be in the list box I would just record a macro and be done with it, but the number will usually be different.  From the reference manual it looks like I should be able to use the ListBox.ListCount property, assign that to a variable, and run a For loop to select all the items in a list, but it doesn't work.  Really I haven't been able to use variables at all in my scripts, and I'm not sure what the problem is.  Here is an example of what I would like to do (in a macro):

 

Dim i

Dim x

 

'Output Cam Files

Application.ExecuteCommand("Define Cam Documents")

x = DefineCamDocumentsDlg.CamDocuments.ListCount

For i = 0 to x-1

DefineCamDocumentsDlg.CamDocuments.Selected(i) = true

Next i

DefineCamDocumentsDlg.CAMDocumentsRun.Click()

DefineCamDocumentsDlg.Close.Click()

 

In this case when I run it I get an error when I try to set x=DefineCamDocumentsDlg.CamDocuments.ListCount, but if I just replace the list count with any number, then it will run and crash out (the CAM dialog box just closes without running anything).

 

I'm open to using this in any combination of a basic script, such as creating a macro string and running that from the script, but I wouldn't know how to get the number of CAM items in the list box in that case.  Any help, or any direction you can point me in to understanding how to use variables or send/return variables to a macro would be great.  I would also love some examples of how to use If statements inside of a macro, if it really is possible (I'm starting to get skeptical of the reference guide...)

 

Thanks,

Jens

Outcomes