X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Jun 2011 02:41 PM by  anon
Input Prompt
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
03 Jun 2011 02:41 PM
    A program that I am writing requires a prompt, but most of the time, the user will be entering the same value so I would like to either: allow the user to just press return, and then the program uses a preset value OR have a preset value already printed, so the user can just press enter For example, if I make a prompt that says, Enter the current Year: I want the user to just be able to press enter (Without typing anything) and the program uses a default value of 2011 Thanks, Alex

    Deleted User



    New Member


    Posts:
    New Member


    --
    07 Jun 2011 02:20 AM
    Hello Alex, This is what you can do : default = 2011 question = string(default, format='(" Do You Want to Use Default Value : ", i4)') res = dialog_message(question, /question) ; Ask to User what he wants to do promptVar = '' if res eq 'Yes' then value = default else begin ; If he wants to use a non-default value he will need to define it. while (stregex(promptVar, '^[0-9]+$', /boolean) ne 1) do $ READ, promptVar, PROMPT='User Value: ' value = uint(promptVar) ; Performing a Cast form String to interger endelse ; OR default = 2011 question = string(default, format='(" do you Wan to use Default Value :", i4," (Yes/No) : ")') promptVar = '' READ, promptVar, PROMPT=question if (strupcase(promptVar) eq 'YES') or (strupcase(promptVar) eq '') then value = default else begin promptVar = '' while (stregex(promptVar, '^[0-9]+$', /boolean) ne 1) do $ READ, promptVar, PROMPT='User Value: ' value = uint(promptVar) ; Performing a Cast form String to interger endelse print, value END Cheers, Vincent
    You are not authorized to post a reply.