BB___CONTENTS

=CONTENTS= toc

Reading A Control
> Reads the contents of a TEXT window, TEXTBOX control, or TEXTEDITOR. Also reads the contents of the text field of the COMBOBOX. The result is stored in variableName$

Writing to Controls
> For TEXTEDITOR (and TEXT window) replaces the contents of texteditor with contents of varname$, or replaces contents of texteditor with the contents of a file opened for INPUT and referenced by **#handle**.

Combobox
> (See selection? for similar command.)

Hints
> code format="lb" input #handle.ext, variableName$ code
 * //**Alternate Syntax.**// Commands that read text from edit controls may also be formatted like this, which is equivalent but outmoded:
 * 1) handle.ext "!contents?"

Text Window
code format="lb" 'reading the contents of a text window nomainwin

WindowWidth = 300 WindowHeight = 370

open "Example" for text as #1 #1 "!trapclose [quit]"

'write some text to the window #1 "Hello World" #1 ""   #1 "This is some text that I wrote." #1 ""   #1 "Done!"

'read the text from the window #1 "!contents? some$"

'displaying the text shows that variable 'some$' contains the contents of TEXT window. confirm "Is this what you wrote?"+chr$(13)+chr$(13)+some$; y$

wait

[quit] close #1 end code

Textbox
code format="lb" 'reading the contents of a textbox nomainwin

WindowWidth = 300 WindowHeight = 370

statictext #1 "Type something: ", 10, 10, 100, 25 textbox #1.tb1 10, 40, 200, 25

button #1.btn1 "Click Me", [doit], UL 10, 100

statictext #1 "You typed: ", 10, 150, 100, 25 textbox #1.tb2 10, 180, 200, 25

open "" for window as #1 #1 "trapclose [quit]" #1.tb1 "!setfocus" wait

[doit] #1.tb1 "!contents? some$" if some$ = "" then notice "Please type something first." #1.tb2 some$ wait

[quit] close #1 end code

Texteditor
code format="lb" 'reading the contents of a texteditor nomainwin

WindowWidth = 300 WindowHeight = 370

statictext #1 "Enter Contact Data: ", 10, 10, 100, 25 texteditor #1.te1 10, 40, 250, 120

button #1.btn1 "Click to continue...", [getContactData], UL 10, 200

open "" for window as #1 #1 "trapclose [quit]" #1.te1 "!setfocus" wait

[getContactData] #1.te1 "!contents? some$" if some$ = "" then notice "Please type something first.":wait

confirm "If contact info is correct, click 'Yes'." +chr$(13)+_ "Your data will be saved to the Database" +chr$(13)+chr$(13)+_ some$;y$

wait

[quit] close #1 end code

Combobox
code format="lb" 'reading contents of combobox edit window nomainwin a$(0) = "Select from list" a$(1) = "Black" a$(2) = "White" a$(3) = "Red" a$(4) = "Blue"

statictext #1.st1 "Please select one:", 10, 10, 100, 25 combobox #1.combo, a$, [doCombo], 10, 40, 120, 200

open "" for window as #1 #1 "trapclose [Quit]" #1.combo "selectindex 1"

wait

[Quit] close #1 end

[doCombo] #1.combo "contents? var$" if var$ = "Select from list" then notice "Invalid selection":wait notice "You chose ";var$ wait code

Texteditor
code format="lb" 'Writing to a texteditor. nomainwin

WindowWidth = 300 WindowHeight = 370

statictext #1 "Contact Data: ", 10, 10, 100, 25 texteditor #1.te1 10, 40, 250, 120

button #1.btn1 "Click to continue...", [getContactData], UL 10, 200

open "" for window as #1 #1 "trapclose [quit]"

gosub [contactList] #1.te1 "!contents contactOne$" wait

[getContactData] #1.te1 "!contents? contact$" if contact$ = "" then notice "Please type something first.":wait

confirm "If contact info is correct, click 'Yes'." +chr$(13)+_ "Your data will be saved to the Database" +chr$(13)+chr$(13)+_ contact$;y$

wait

[quit] close #1 end

[contactList] contactOne$ = "Peter Wolff" + chr$(10)+_ "123 Lonely Lane" + chr$(10)+_ "Wooden Valley, EU"

return code

A snippet from the JustBASIC Help file: code format="lb" 'Writing the contents of a file to a text window open "Contents of AUTOEXEC.BAT" for text as #aetext

open "C:\AUTOEXEC.BAT" for input as #autoexec print #aetext, "!contents #autoexec"; close #autoexec 'stop here input a$ code

Useful Functions
code format="lb" Place a useful function using this keyword here code