Welcome to iraf.net Friday, May 17 2024 @ 07:19 AM GMT
piverson |
04/24/2008 09:52PM (Read 1837 times)
|
|
|
Status: offline
Registered: 07/10/2007
Posts: 42
|
Mike-Does SPP support case structures? If so, can you give me a simple example of the syntax?Thanks.
-Paul
|
|
|
|
fitz |
04/24/2008 09:52PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
Are you asking about SPP (the compiled language now shunned by all but the truly enlightened), or CL scripts?In both cases the answer is yes. For SPP the syntax is[code:1:1ead02db37]
switch (int_expr) { SWITCH CASE construct
case int_const_list:
statements
case int_const_list:
statements
default:
statements
}
[/code:1:1ead02db37]Where 'int_expr' would include things like a single character if you wanted to switch over keystrokes.For CL scripts the basic structure is the same but the switch value can be a script variable, a constant, a cursor/keystroke read. or even an expression. It is most often used (by me anyway) to put keystroke interactivity into a script. For example:[code:1:1ead02db37]
switch (ch) {
case "?":
{
print ("you need help")
}
case "t":
{
printf ("something clever here ")
}
default:
print ("Invalid command")
}
[/code:1:1ead02db37]Note that don't need a BREAK statement, the code block executes and doesn't fallthru to the next case the way it does in C.Cheers,
-Mike
|
|
|
|
| |
|
Content generated in: 0.09 seconds |
|