gaslouk
Full Member
Hi from beautiful Greece.
Posts: 130
|
Post by gaslouk on Mar 31, 2023 1:54:27 GMT -5
Hi.
Peculiarities of print in liberty. Ways of using. Special usage practices.
Thanks. Gaslouk.
|
|
|
Post by xxgeek on Apr 2, 2023 0:39:49 GMT -5
You've picked a real winner with Print. There is a lot to explain. I'll take a poke at this and try to keep it simple.
NOTE : Be aware that for most uses of print, you do not need to actually use the word print, it is implied. eg: print #test.textbox, myText$ can be written #test.textbox myText$ But if you do use print, you MUST also use the comma preceding the control as shown above.
The Print command is used in different ways that have nothing to do with printing to paper on a printer. We can print to the mainwin, to a file, to a window, to a control, and to a device. Controls include textboxes, texteditors, checkboxes, buttons, etc - see GUI Programming in Help
1. The main use of command 'Print' eg: Print "Hello World" or Print myVariable$ or Print MyVariable Prints "Helo World" to what is known as the mainwin. The mainwin is the page that pops up when you run one of your programs in the Liberty Basic IDE, if you do not include the command 'nomainwin' somewhere in your program. eg: sometext$ = "Hello World" print sometext$ someNumber = 10 print someNumber Many LB programmers use it for debugging purposes, by printing variables etc during program execution.
2. Printing to a file - eg: print #file sometext$ sometext$ = "Hello World" open "some\file\name.ext" for output as #file print #file, "Hello World" print #file, sometext$ print #file someNumber close #file
3. Printing to a control (some text) - eg: print #test.textbox "Hello World" nomainwin textbox #test.textbox, 100, 200, 120, 25 button #test.button, "Change", [change], UL, 120, 110, 75, 30 open "Test Window" for window as #test print #test, "trapclose [quit]" print #test.textbox, "Hello World" wait
[change] if change = 1 then print #test.textbox, "Hello World" : change = 0 else print #test.textbox, "Goodbye World" : change = 1 end if wait
[quit] close #test end All of the above print statements, and preceding commas can be removed.
3. Printing to a control (a command) eg: Print #test.textbox, "!hide" This prints a command to the textbox, which tells the textbox to hide. again, no need to type print -- #test.textbox "!hide" -- works just as well
Print is used for so many commands it would take too long to list them all. But remember, you don't actually need to use print in most cases, it is still used in Liberty Basic to be compatible with earlier versions.
See GUI Programming, Text Commands, and Graphic Commands in Help for a long list of commands used with controls.
Also, search the forums for a 'help search' engine to search the help files using keywords. Stefan Pendl is the author. I have a copy of the source code if needed, but it cannot be redistributed according to Stefan Pendl, unless major changes are made to it.
|
|
|
Post by Walt Decker on Apr 4, 2023 9:27:12 GMT -5
Most members here think of print for "sequential" file mode only. However, it is also used with "binary" mode files which are much more versatile than sequential mode and "random" mode files.
|
|