Note that the code for getting user input is the same in graphical mode as in text mode. If Frink is running in a graphical mode, it will produce graphical inputs. If running in text mode, it will take input from stdin.

This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.

Module CheckIt { Def aName$="No Name", Num$ \\ we open a new stack, and hold old Stack New { If Ask$("Give your name:",,,,,aName$)="OK" Then Read aName$ If Ask$("Give a Number: (75000)",,,,,"")="OK" Then Read Num$ if Num$<>"75000" or aName$="" Then loop } \ now old stack came back Print Num$, aName$ Print Letter$ \\ Letter$ pop a string from stack}CheckIt "Thank You"

We use two textboxes in a user form. Each one has an event ValidString. The first textbox as we type display the number of characters that we can add. Also remove any leading space.

Each text box can be used for text, with a prompt (of we want), and a ThisKind at the end. Cursor can be move inside Vartext, the text that we place. Text in textbox may horizontal scroll automatic. We can use Home, End, Delete, Enter, Left and Right Arrows, Ctrl+V to paste (paste replace all text. we can't copy), and Tab and Shift Tab to change focus to other controls. There is no undo (Undo has the EditBox).

The second textbox change sign using + - in any position (we have to press + when sign is -). Only "-" sign displayed. Also except for zero all other numbers have no leading zeros.

Form Form1 open modal, so we can close it clicking a square in title bar, or using Alt+d2F4

\\ local1, and Event service functions have module visibility. \\ So they have to use Read New to make new references (shadow old), and use local (the same for SUBS) \\ Event's service functions can't use parents Subs, but Local1 can be used (exist in a list visible to Events) Function Local1 (new Feed$) { \\ this function can be used from other Integer \\ this$ and thispos, exist just before the call of this function local sgn$ if feed$="" and this$="-" then thispos-- : exit if left$(this$,1)="-" then sgn$="-": this$=mid$(this$, 2) if this$<>Trim$(this$) then this$=Feed$ : thispos-- : exit If Trim$(this$)="" then this$="0" : thispos=2 : exit if instr(this$,"+")>0 and sgn$="-" then this$=filter$(this$, "+") : sgn$="" if instr(this$,"-")>0 and sgn$="" then this$=filter$(this$, "-") : sgn$="-" if filter$(this$,"0123456789")<>"" then this$=Feed$ : thispos-- : exit if len(this$)>1 then While left$(this$,1)="0" {this$=mid$(this$, 2)} this$=sgn$+this$ if this$="-0" then this$="-" : thispos=2 } Function Inp1.ValidString { Read New &this$ While left$(this$, 1)=" " { this$=mid$(this$, 2)} info$=str$(30-Len(This$), "\<0\>") } Function Inp2.ValidString { \\ this function called direct from textbox Read New &this$, &thispos Call Local local1(Feed$) } Function Form1.Unload { Read New &Quit If feed$<>"75000" Or Aname$="" then { \\ open messagebox, pressing cancel quit Unload Quit=Ask("Data isn't correct")=2 } } Method Inp1, "Move", 2000,2000, 6000, 600 Method Inp2, "Move", 2000,3000, 6000, 600 Method Form1, "Show", 1 If Feed$="75000" and Aname$<>"" Then Print "Thank You" Declare Form1 Nothing }Checkit

; There is a bug in the "gs:get-text" function that causes it to fail; silently if the text field is empty. Therfore, I set the field; background to red first and only clear it if the field returns; correctly.(define(validate)(gs:set-color'string fail)(if(not(empty?(gs:get-text'string)))(gs:set-color'string ok))

; Create main window frame and set layout.(gs:frame'main100100256128"User Input/Graphical")(gs:set-flow-layout'main"left"44)

; Create and add widgets.(gs:label'instructions"Please enter a string and the number 75000:")(gs:text-field'string'validate32)(gs:text-field'number'validate8)(gs:button'check'validate"validate...")(gs:add-to'main'instructions'string'number'check)

FUNCTION PBMAIN () AS LONG result$ = INPUTBOX$("Enter a string.") MSGBOX result$ DO 'This assumes that 75000 is the ONLY valid input. result$ = INPUTBOX$("Enter the number 75000.") IF VAL(result$) <> 75000 THEN MSGBOX "You need to enter 75000!" ELSE MSGBOX "You entered the right number." EXIT DO END IF LOOPEND FUNCTION

As a scripting/console language PowerShell was not designed for graphical interfaces.
However, since PowerShell is a fully qualified .NET language the full functionality of the
System.Windows.Forms assembly is available.

### Show the input form$f=$Form1.ShowDialog()if($f-eq[System.Windows.Forms.DialogResult]::Cancel ){"User selected Cancel"}else{"User entered `"{0}`" for the text and {1} for the number"-f$txtInputText.Text,$txtInputNumber.Text }

; Simple GUI's can be defined with 'layout', a special purpose dialect; for specifying interfaces. In this case, I describe a gradient; background with an instruction label, followed by the input fields; and a validation button. It's possible to check dynamically as the; user types but I wanted to keep this example as clear as possible.

viewlayout[

; You can define new widget styles. Here I create a padded label style; (so that everything will line up) and a simple indicator light to; show if there's a problem with an input field.

style label vtext 60"unlabeled" style indicator box maroon 24x24

backdrop effect [gradient 0x1 black coal]

vtext "Please enter a string, and the number 75000:"

; By default, GUI widgets are arranged top down. The 'across' word; starts stacking widgets from left to right. 'return' starts a new; line -- just like on a typewriter!

across

; Notice I'm using my new label and indicator styles here. Widgets; that I need to access later (the input field and the indicator) are; assigned to variables.

label "string:" s: field 240 si: indicator return

label "number:" n: field 50 ni: indicator return

pad 66 button "validate"[

; The user may have entered bogus values, so I reset the indicators:

si/color: ni/color: maroon

; Now I check to see if the values are correct. For the string, I just; care that there is one. For the integer, I make sure that it; evaluates to an integer and that it's value is 75000. Because I've; already set the indicator colour, I don't care the integer; conversion raises an error or not, so I ignore it if anything goes; wrong.

In addition, it checks for errors such as no string entered (or it is blanks or null), and
it verifies that the correct number has been entered.

/*REXX pgm prompts (using the OS GUI) for a string & then prompts for a specific number.*/ #= 75000/*the number that must be entered. */string=nubber=dowhile string=' '/*string can't be blanks or null string*/saysay'Please enter a string: 'parsepull stringif string=''thensay'***error*** No string entered.'end/*while string···*/

The Sensing block "ask _____ and wait" pops up a word balloon with a question in it and waits for user input. The input is returned in "answer," essentially a special variable. It can be treated as a string or a number, depending on context. "Answer" cannot be modified, but its value can be stored in other variables.

Displays a dialog box with two input fields and default OK button. The values entered are stored in text registers 1 and 2.
The value from 2nd field is then converted into numeric value. (Accepts integers or integer expressions.)

Visual Basic can use the above VBScript or PowerBASIC examples unchanged (aside from changing PB's FUNCTION PBMAIN to Sub Main).

Alternately, a form could be easily created (using the form designer) to get both values at once, but that is a task almost never done at runtime, instead being done within the IDE while creating the program.