Subscribe Bookmark RSS Feed

Choose 1 Directory script

j_bonnouvrier

Community Trekker

Joined:

Dec 19, 2012

Hi,

In the script enclosed, it is proposed to the user to select one directory in a list.

The selection is stored in a list of strings called "choixproduits".

The variable "produit" is set to the value of the first element of the list at line 38.

My concern is that it returns an empty string. Probably a problem in string of caracters manipulation, but I can't figure out how to solve this issue.

Thanks in advance is anybody has the solution!

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Since the window is not modal, the assignment produit = Choixproduits[1]; is executed before the user has a chance to click ok. That's why produit is empty.

Either make the window modal, or put the assignment within the button script.

For example:              

produit = (RESP << Get selected)[1]

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

Since the window is not modal, the assignment produit = Choixproduits[1]; is executed before the user has a chance to click ok. That's why produit is empty.

Either make the window modal, or put the assignment within the button script.

For example:              

produit = (RESP << Get selected)[1]

j_bonnouvrier

Community Trekker

Joined:

Dec 19, 2012

Thanks a lot, you gave me the clue!

I finally added a flag preventing any further JSL statement to be executed before the OK button has been clicked by the user:

/* Create a flag that will be set when the user dismisses the window */

while_flag = 0;

V List Box(

Button Box( "OK",

produit = (RESP << Get selected)[1];

while_flag = 1; // Flag changes to 1

nw << Close Window;

);

/* If while_flag is 0, JMP will wait */

While( !while_flag, Wait( 0.1 ) );