Source language: Translate to:

Ifex

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Ifex

Postby Carl_SA » Thu Aug 24, 2006 4:18 am

Could someone please help me with the following:
I cannot seem to get the following to work. I have tried removing spaces etc but to no avail.

IfEx "[A] > 0 AND [A] < 50"
SetObjectFill "TextEntry38" "255,128,0" "Solid" "False"
EndIf

I have tried different variations but just cannot seem to get this to work.
Carl_SA
 
Posts: 91
Joined: Sat Dec 17, 2005 12:47 am

Postby Sam Cox » Thu Aug 24, 2006 4:32 am

Hello Carl_SA,

A couple of things to try:

1. surround the subexpressions with parens:
Code: Select all
IfEx "([A] > 0) AND ([A] < 50)"
  SetObjectFill "TextEntry38" "255,128,0" "Solid" "False"
EndIf

2. prefix each variable with "0" just in case [A] is blank.
Code: Select all
IfEx "0[A] > 0 AND 0[A] < 50"
  SetObjectFill "TextEntry38" "255,128,0" "Solid" "False"
EndIf

With IfEx "expression" and WhileEx "expression", be careful when writing the "expression". The "rules" for IfEx and WhileEx I have discovered so far are:

1) Anticipate that variables may be empty or blank

By surrounding variables with pseudo-quote characters (A), or by padding variables with constants (B), you can be sure that an empty variable will not cause trouble.
Code: Select all
A: IfEx "{[TextEntry1]} = {sam} or {[TextEntry1]}={theresa}"
B: IfEx "[TextEntry1]XX = samXX or [TextEntry1]XX = theresaXX"

2) Be careful about spaces in IfEx and WhileEx expressions

The following expressions work. Notice the variety of spacings in these commands:
Code: Select all
A: IfEx "{[TextEntry1]} = {sam} or {[TextEntry1]}={theresa}"
B: IfEx "{[TextEntry1]}={sam} or {[TextEntry1]}={theresa}"
C: IfEx "{[TextEntry1]} = {sam} or {[TextEntry1]}={theresa}"
D: IfEx "{[TextEntry1]} =     {sam}    or  {[TextEntry1]}={theresa}"

The following expressions do not work because the joining operator ("or" in these examples) is not separated distinctly from the sub-expressions.
Code: Select all
E: IfEx "{[TextEntry1]}={sam}or{[TextEntry1]}={theresa}"
F: IfEx "{[TextEntry1]}={sam} or{[TextEntry1]}={theresa}"
G: IfEx "{[TextEntry1]}={sam}or {[TextEntry1]}={theresa}"

3) Double-quotes are necessary when a comparison item contains spaces

Neobook's help file states that when "a comparison item contains spaces, then it must be surrounded with quotes." That is, instead of writing this:
Code: Select all
IfEx "{[value]} = {one two} or {[value]} = {three four}"

you should write this:
Code: Select all
IfEx "{[value]} = [#34]{one two}[#34] or {[value]} = [#34]{three four}[#34]"

The explict quotes [#34] alert the IfEx parser to the boundaries of the expression to be compared.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Carl_SA » Thu Aug 24, 2006 4:54 am

Hi,

Thanks for this. Reading through your response made me try surrounding my variables with the [#34]. For some reason I thought that the variables would be immune to this rule.

Works fine now.

Thanks once again
Carl_SA
 
Posts: 91
Joined: Sat Dec 17, 2005 12:47 am

Postby Gaev » Thu Aug 24, 2006 5:00 am

Carl_SA:
I cannot seem to get the following to work. I have tried removing spaces etc but to no avail.
From the title of your post I am assuming that you think the IfEx command is not evaluating the value of [A] correctly ... I tried this code ...
Code: Select all
IfEx "[A] > 0 AND [A] < 50"
    AlertBox "True" "[A]|A>0 AND a<50"
Else
    AlertBox "False" "[A]|A>0 AND a<50"
EndIf
... with [A] associated with a TextEntry Box ... and it worked as expected ... null values (False), 0 (False), 0.1 (True), 44.9 (True), 50 (False) and 51 (False) ... also abcd (False).

Perhaps you are judging the evaluation of IfEx by what you see the result of SetObjectFill.

If [A] can contain decimal points, do you have an operating system option that treats commas (,) instead of the Anglo-American dots/points (.) as the decimal separator ?

Try the above code in a separate pub and see if you get similar results.


Oops - looks like some activity while I was composing/testing my response ... what version of NeoBook do you have ... I believe the "null value" issue has been resolved in the latest version(s) ... unless
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests

cron