Welcome to iraf.net Friday, May 17 2024 @ 07:19 AM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 Case structures in IRAF scripts
   
piverson
 04/24/2008 09:52PM (Read 1837 times)  
+++--
Chatty

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

 
Profile Email
 Quote
fitz
 04/24/2008 09:52PM  
AAAAA
Admin

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

 
Profile Email
 Quote
   
Content generated in: 0.09 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login