Problem with custom valuelists in Servoy 4.1 b2

I am trying to set up a custom value list in Servoy 4.1 b2, but can’t get it to work properly.

I started by setting up the value list in the same way as I did with Servoy 3.5. That was just a plan and simply text list. Each row in that text list was supposed to be one of my custom values. However, that simply wouldn’t work. I therefore had a look through the docs for Servoy 4. I found that I needed to use a pipe ( | ) to separate the value list text from the value that I wanted to return. An example of what I’m talking about is typed below:

Telephone Line|telephone
Mobile Line|mobile
Fax Line|fax

(Telephone Line would appear in the list, while ‘telephone’ would be stored, if telephone line was actually selected.)

The value list was set up to full a list of radio buttons. The selected value from those buttons was set up to be stored to a global variable in my solution. However, I simply couldn’t get this to work properly. I set up a field in the form that I was working on, so that it showed me the value of the corresponding global variable. I then tried using the radio buttons to select values from the list. When I did this the correct value seemed to be showing up in the global variable, (as I could see its value in the field mentioned above). However, I was having problems when trying to use the value from that variable.

The following code is used when a user clicks a button to confirm that they’ve selected a line type. This code is giving me some very strange problems:

	if (g_line_type == "telephone" || g_line_type == "mobile" || g_line_type == "fax")
	{
		application.closeFormDialog();
	}
	else
	{
		plugins.dialogs.showInfoDialog('Line Type Selection', 'You must select a line type before creating a new line.','OK');
	}

Basically, ‘g_line_type’ is the global variable that stored the returned value. Also, the field in my form shows me that the variable does actually store one of the 3 values in the condition. However, every time I run this code, the else part of the condition gets activated instead of the bit that closes the form dialog. This means that I get the ‘info’ dialog opening, when the ‘form’ dialog is actually supposed to close. As I said above this is in situations where the global variable seems? to have one of the 3 values in the condition.

I’ve spent a load of time trying to sort this out, but nothing will work for me. I’ve tried using integers instead of strings (as the returned values from the value list). I’ve also tried rebuilding the various components numerous times as I switch between different data types. I always seem to hit the same problem, regardless of what I try to do to fix it. Therefore, if anyone out there has any suggestions on how I can sort this out, please let me know.

Thanks in advance for your time.

Craig

Stupid question: if g_line_type is a global, shouldn’t you check for globals.g_line_type == “telephone”?

patrick:
Stupid question: if g_line_type is a global, shouldn’t you check for globals.g_line_type == “telephone”?

Hi,

Thanks for that. Your right, I should have seen it myself.

Cheers

Craig