Error in IfEx block - Forum

Forum Navigation
You need to log in to create posts and topics.

Error in IfEx block

Hi,

I'm creating an application and I'm encountering an issue with a code block where a series of IF statements are being used.

I need to check a code within the box and color the box based on the selected content.

However, even though the code is not the same, the program still executes the code within the IF condition.

Attached is the image of the error.

Uploaded files:
  • You need to login to have access to uploads.

My guess is that it looks like both strings are being interpreted as numeric expressions, so

828905 - 1 = 828904

and

828906 - 2 = 828904

And so they are seen as equal in the IfEx action. I don't know enough to suggest the how to stop this, but I imagine someone with more experience than me in VisualNEO Win will know a solution?

I put the variable as TEXT, but I have the same problem

Uploaded files:
  • You need to login to have access to uploads.

@nikyred, I think @susan is right. Please prepend "!" to the variables value to avoid VisualNEO Win doing the math operation.

Example:

SetVar "[myVar]" "!828905 - 1"

Please, let me know if this solves the issue.
Regards.

susan has reacted to this post.
susan

I tried to put ! , but it does not work.

Can I send you the TEST file so I could check it?

the only thing if I can send it to you privately

First, your conditions are written incorrectly.
Should be:

IfEx ""

Else

EndIf

But not:

IfEx ""

Else

Else

Else

EndIf

Replace Else with EndIf everywhere. And let me know.

Secondly, if you think that something is not working correctly, use AlertBox . For example:

IfEx ”[Pressa50_PN1] = 963243-1" 
AlertBox "" "[Pressa50_PN1]" 
SetObjectFill"Pressa50_PN1“ "34,113,179" "Solid" "False" 
SetObjectFont "Pressa50_PN1" "Black" "Arial" "14" "Normal" "ANSI_CHARSET" 
EndIf
Quote from mishem on August 21, 2023, 3:34 pm

First, your conditions are written incorrectly.
Should be:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
IfEx ""
Else
EndIf
IfEx "" Else EndIf
IfEx ""

Else

EndIf

But not:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
IfEx ""
Else
Else
Else
EndIf
IfEx "" Else Else Else EndIf
IfEx ""

Else

Else

Else

EndIf

Replace Else with EndIf everywhere. And let me know.

 

 

Thank you for your suggestion.

I tried to edit but it didn't solve the problem.
but I replaced this "-" symbol with this "_" and it works.

So it is confirmed that VisualNeo is likely doing a mathematical calculation.
I tried adding the "!" symbol to the variable. but it doesn't resolve.

I will try to make the selection in number and not in Text, in the box. So then in the program in the condition comparison with a number and not with a Text

Ifex isn't need here. It is for multiple conditions. You can use:

if

else

endif

instead.

Quote from nikyred on August 21, 2023, 4:24 pm
but I replaced this "-" symbol with this "_" and it works.

Alertbox shows subtraction or a whole line? I have a whole line.

@nikyred

I think @mishem has the right reason ... unlike some other languages, NeoScript does NOT support multiple Else code blocks within If and IfEx commands.

This small example worked for me ...

...AlertBox "Selection" "[ListBox1]"

IfEx "[ListBox1] = 828906-1"
   AlertBox "828906-1" "selected"
   Return
EndIf

IfEx "[ListBox1] = 963142-2"
   AlertBox "963142-2" "selected"
   Return
EndIf

 

... where my ListBox had just two entries viz. 828906-1 and 963142-2 (ok, I was too lazy to add more entries).

So, in your pub, add the appropriate commands in place of the AlertBox (after it is seen to work for you).

In case it is relevant, I found this in the definition of the SetVar action in the Help. I presume attempting to evaluate a string as a mathematical formula might apply to strings in contexts beyond the SetVar action?

Uploaded files:
  • You need to login to have access to uploads.
Quote from nikyred on August 21, 2023, 3:13 pm

I tried to put ! , but it does not work.

Did a little experiment. The AlertBox displays the correct variable value as 828906-2.

IfEx performs a mathematical operation on both the variable and the value. So it should be written like this:

IfEx "![ComboBox1]=!828906-2"

Gaev has reacted to this post.
Gaev

Hi,

Thanks for everyone's support.

I tried your advice but with no success.

I then chose to transform the Box selection into a numeric value. In this case everything works :)