Video Screencast Help
Scheduled Maintenance: Symantec Connect is scheduled to be down Saturday, April 19 from 10am to 2pm Pacific Standard Time (GMT: 5pm to 9pm) for server migration and upgrade.
Please accept our apologies in advance for any inconvenience this might cause.

In Wisescript how to populate custom dialog list box from multiline variable

Created: 01 Dec 2011 • Updated: 11 Dec 2011 | 7 comments
This issue has been solved. See solution.

Hi all,

Currently we are using Wisescript 7.0 sp1.  I am able to successfully read a multiline text file into a variable. Then take the variable and have it show up in the list box.  The issue I am having is how do I tell it to show each line in the dropdown/listbox so all lines of the previous text file are showing and will be usable to pick from.  Right now only the first line shows up and if I hit ok the next line shows up etc.  I have tried many variations of combining with %CRLF% etc but can't seem to get it to read the whole variable into my list box.  Any suggestions or help would be most appreciated.

 

Thanks!

 

Nick

Comments 7 CommentsJump to latest comment

EdT's picture

Can you provide a specific example of what you are trying to achieve?  It's hard to formulate a relevant suggestion without this.

Are you trying to display a delimited string of options on a "one per line" basis and have a user select one of the options or make multiple selections?  Or are you just trying to display a column of data as information to the user?

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

TheHoff's picture

Yes basically I am pulling a list of print queues rom a text file into the variable.  Then I am taking that variable and trying to populate a combo box.  Once this is complete the person who launched the script will be able to choose the print queue they desire.  Depending on what printe queue they select it will use that as the new variable content and insert it into a command to add the printer.  The problem I am having now is in my custom dialog combo box.  My dropdown box doesn't popluate all lines unless I click the push button (Select in my case) and then it will populate the next line of the variable and append it to the drop box.  I put in the while statement to see If I could get it to run through line by line until I selected something but it isn't working it still needs me to click the push button to populate the next line.

Example:

printer.txt looks like this.

queue1

queue2

queue3

 

Wise sample code:

Set Variable PRINTLIST to

Read lines of file c:\temp\printers.txt into varialbe ALLPRINTERS Start Block

Set Varaible PRINTLIST to %PRINTLIST%%ALLPRINTERS%%CRLF%

Set Variable PRINT to

While Print Equals "" loop

Custom dialog "print Queue"

 

end

I have also tried to add a while loop inside the dialog script editor... What am I missing?

EdT's picture

I believe you can achieve what you want using a List Box rather than a combo box.

I have put together a simple example based on a string delimited with %CRLF% where you can select one line and have it displayed as a result. The source WSE and the EXE are in the attached ZIP. The function is really simple to set up once you have your data string.

AttachmentSize
Test.zip 143.26 KB

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

TheHoff's picture

What you sent is what I tried originally from a similair article, but it still only brings in the first line of the variable.  It is popluating the list box/drop box type doesn't matter so far, but I still have to hit the ok each time to get the new line from the variable.  Is there away to simulate me hitting the push button possibly in a while loop until the criteria is met.  Then once that criteria has been met the user can pick from the list.

 

Thanks for your help!

 

Nick

EdT's picture

I do not see why you need a "While" loop - also, you show only one "End" statement but there need to be two, so I think I know why this is going wrong.

The Read Lines from Text File command is a Looping command just like the While command. So what you need to run first is this:

 

Set Variable PRINTLIST to

Read lines of file c:\temp\printers.txt into varialbe ALLPRINTERS Start Block

Set Variable PRINTLIST to %PRINTLIST%%ALLPRINTERS%%CRLF%

End 

This block of code will now read in one line at a time and will loop until all lines are read and your PRINTLIST variable is fully populated.  You can single step the Wisescript editor to watch the code work step by step, or you can put in a Display command after this block of code to display %PRINTLIST% so that you can check it is what you expect.

THEN you can display the %PRINTLIST% variable in your custom dialog.  At the moment, the single END statement you have in your code is causing the code to read one line from the text file, and then immediately go to the Dialog. Then if you press continue on the dialog, it loops back and reads the next line and then displays two lines, etc, etc.

Is this where you are going wrong?

If not, drop me an example of the printer.txt file and let me expand the code sample for you.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

SOLUTION
TheHoff's picture

So the End statment was the issue.  This segment  is part of a much larger script and I have If statements all over the place.  Thanks again for your help!

 

Nick

EdT's picture

The compiler normally barfs with error messages if the number of end statements does not match up with the number of if/while/read line commands, so I'm guessing there may have been another error in your code somewhere else.

As you have found, when the code gets lengthy and involved, it can be quite tricky to match up the end statements. What I find useful is to insert remark statements in capitals, appropriately indented (as you cannot indent the actual commands themselves), and use this as a tracking aid to identify the start and end points of any "looping or branching" section of code.  The single step function is also a massive help in debugging sections of code, as you can always preset the variables and then watch what happens as it steps through.

Glad it is now sorted!

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.