Welcome to iraf.net Friday, May 03 2024 @ 12:48 PM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 scanf doesn't wait for input when scripted
   
Fenris
 03/12/2007 04:48PM (Read 4857 times)  
+----
Newbie

Status: offline


Registered: 02/14/2007
Posts: 7
I'm doing some scripting in IRAF, and would like to read a filename from the standard input (keyboard) into a string variable in order to then perform operations on the file in question. Something like this should work, I thought anyway:[code:1:7a4d5c03c3]string filenameprint('Enter file to process: ')
scanf("%s", filename)print('Processing ', filename, ' now.')[/code:1:7a4d5c03c3]However, the scanf command doesn't pause and allow any input, it just races through to the end of the code and finishes, with the following printed to screen:[quote:7a4d5c03c3]da> cl < bethany.cl
Enter file to process:
Processing now.
da>
[/quote:7a4d5c03c3]I seem to recall the same thing happening when doing some simple C coding on my Windows terminal at home, but I've looked around and as far as I can tell that's the correct form to use scanf in. Also, if I simply declare the variable and type in the same scanf command line at the cl> prompt, it works just fine and I can enter a string value as planned.What am I doing wrong, and/or is there another way to achieve the same goal?Many thanks.

 
Profile Email
 Quote
fitz
 03/12/2007 04:48PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
When you redirect the input to run the script, you redirect ALL the input, and so the scanf is being answered by the next line of the file. You need to turn this into a procedure script for it to run as expected (see the Script Programmer's Guide, https://iraf.net/irafdocs/script for details) -Mike

 
Profile Email
 Quote
   
Content generated in: 0.06 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