| Purpose |
With if you can make script commands
dependent on conditions. For example, on the current
GUI-Status or on whether certain fields exist in the R/3
screen. |
|
Example
|
if Q[Status=ADD1] or Q[Status=UPD1]
Image (1,50) (10,90) "imgupd.gif"
else
Image
(1,50) (10,90) "imgdis.gif"
endif If the GUI Status is ADD1 or UPD1, the image file "imgupd.gif" will appear,
otherwise "imgdis.gif" will appear.
|
| Conditions |
What conditions are available with if
?
Firstly, you can look for the
existence of screen elements by simply naming the
corresponding screen element in the if command. For example:
- if F[Amount] means: "if there
is a field Amount on the
screen".
- if I[Amount] means: "if there
is an input field Amount on the
screen".
- if P[Cancel] means: "if there
is a Cancel pushbutton on the
screen".
Secondly, you can inquire about certain status
data:
- if Q[Status=xxxx] If the
GUI-Status is xxxx
- if Q[Language=x] If the
language key is x (1 character, E=English,
D=German, F=French, I=Italian,...)
- if Q[Database=xxx] if the system
(database server) id is xxx
- if Q[Client=xxx] if the client
is xxx
- if Q[User=xxx] if the user
is xxx (see Role
specific user screens)
- if
Q[Role=xxx]
If the role
is xxx (see Role
specific user screens)
- if
Q[Profile=xxx]
if the profile
is xxx
- if Q[Transaction=xxxx] If the
transaction code is xxxx (N.B. only possible with
R/3 Rel.4 and upwards)
- if Q[ScreenVariant=xxxx] if an R/3
screen variant xxx is active (with a central
GuiXT script)
- if Q[GuiXTVersion=yyyy
Qx x] if
the GuiXT
Version is equal to yyyy Qx x. You can use <, = or >. See
also TIps & Tricks below.
- if Q[StopRequest]
if
the user has provoked a StopRequest in an InputScript (see StatusMessage)
- if Q[Page=xxxx] if the
current page of a tabbed dialog is xxxxx (xxxxx
is the text displayed on the tab)
- if V[vname=value] if the
variable vname has the value value (only possible
with InputAssistant)
- if U[uname=value] if the using
parameter uname has the value value (only
possible with InputAssistant)
Thirdly you
can inquire about user options set in guixt.ini:
Option
opt1
Option opt2
with
if
Q[Option=xxxx]. For example, you could offer
an option HelpDisplay. When the user
activates this option in guixt.ini, you could display a
help text for certain transactions, either as image file
using Image or as rtf or html
file using View. Each user can then
decide individually whether or not to use the help
text.
You can define up to 50
different options in guixt.ini, each Option string containing up
to 30 characters.
|
Is it possible
to use nested
if
else
endif ?
Are logical
expressions permitted ?
|
Yes, both are possible.
Example:
if not Q[Status=UPD1]
Image
(1,50) (10,90) "imgdis.gif"
else
if
(F[Company
code] or F[Business
area]) and
not
F[Order number]
Image (1,50) (10,90) "imgupd1.gif"
else
Image
(1,50) (10,90) "imgupd2.gif"
Pushbutton
(Toolbar) "Cancel"
"/OZC27"
endif
endif
You can use
normal brackets, "and", "or" and "not" within logical
expressions. Normal rules of logic apply for priority and
bracketing.
Inquiring
about field values is not possible. With
InpuAssistant you can inquire about global variables that
can be set in GuiXT Scripts and InputScripts.
|
Tips
& Tricks
|
- A field, e.g. F[Company
code], cannot be specified directly in an if statement, please use a
variable. Example:
Set
V[buk]
"&F[Company code]"
if
V[buk=0001]
...
endif
- In order to compare two
variables V[x1] and V[x2], you have to use the value &V[x2]
in "if V[x1=value]":
if
V[x1=&V[x2]]
...
endif
- For details
concerning if Q[Role=xxx]
and
if Q[Profile=xxx]
see Role
specific user screens
- "if
Q[GuiXTVersion..." is supported in GuiXT version 2002 Q4 3
and upwards. If you want to ensure that in your script (probably the logon
script) the installed GuiXT version is at least 2002 Q4 5, you
can use the following coding:
if Q[GuiXTVersion<2002 Q4 5]
Message "Please install new GuiXT versions \nFor questions
contact S. Bauer ext. 2649" Title="Update
necessary"
endif
But in this case no message would appear in the versions prior to 2002
Q4 3, since the condition if Q[GuiXTVersion<....] didn't yet
pertain, and the indication "false" is returned. In order to cover such
cases as well, use "not ... >" with the previous GuiXT
version id:
if not Q[GuiXTVersion>2002 Q4 4]
Message "Please install new GuiXT versions
\nFor questions contact S. Bauer ext. 2649"
Title="Update necessary"
endif
- You should not use Screen
commands within if
... endif,
since this makes the script hard to understand, and sometimes the
behavior will be quite unexpected. Bad example:
Screen S1
Set V[x] "a"
Enter
if V[x=b]
Screen S2
Enter "xx"
else
Screen S2
Enter "yy"
endif
Assume that we
have Screen S1 and then Screen
S2. Does GuiXT now process Enter "xx" or Enter
"yy"? In fact, in this example, Enter "xx"
is executed, since GuiXT looks for the next matching Screen command
for Screen S2, without considering open if statements of previous
screen blocks.
Instead, please close all open "if" statements in each
screen block:
Screen S1
Set V[x] "a"
Enter
Screen S2
if V[x=b]
Enter "xx"
else
Enter "yy"
endif
In some
cases it makes sense to use goto/label:
Screen S1
Set V[x] "a"
Enter
if V[x=b]
goto l_b
endif
Screen S2
Enter "xx"
goto l_continue
label l_b
Screen S2
Enter "yy"
label l_continue
|