|
Post by DARKNIGHT on Dec 1, 2022 0:03:35 GMT -5
I'm trying to use a GUI Text Window to create a sort of word processor to create a form template. for another app I have been working on. How do I get the output from a text window ? Have been away from LB for Quite a few years and am still having trouble remembering how to do certain things in LB.
|
|
|
Post by Rod on Dec 1, 2022 3:33:56 GMT -5
You would get better advice showing us your code or an extract. If you are using a window of type text then
print #handle, "!contents? string$"; This command returns the entire text of the window. After this command is issued, the entire text is contained in the variable string$.
But a text window is not used that often. Forms and templates are better handled with text boxes or text editors. Show a little of what you are trying to do. Even just an example of the text you expect to get back.
|
|
|
Post by DARKNIGHT on Dec 1, 2022 13:43:09 GMT -5
Thank you for answering.Here is my code thus far: Open "example" for text as #1 Print #1,"!contents? C$" wait Print C$
Where do I use the print statement to get it to print in the mainwin? Just to make sure I did that's right? I tried before the wait statement and after it, all to no avail. . . . I'm very rusty on GUI apps. And the programs help text is not much help
|
|
|
Post by xxgeek on Dec 1, 2022 14:24:52 GMT -5
Jim, you haven't given C$ a value in your code, so there is nothing to print.
After thinking on this I believe you have a textbox you wish to get the results from, but you are opening a text window, not a textbox in your code.
You first need to create a window and add a textbox. then you can get the text from the textbox and print to mainwin
If I have got this wrong, please explain in detail what you want to accomplish. This is why we ask to see the code you are working with. eg:
'type something into the textbox, and the text will appear in mainiwin button #1.ok, "ok", [ok], UL, 100, 140, 100, 30 textbox #1.tb 40, 35, 218,32 Open "example" for window as #1 #1 "trapclose [quit]" wait
[quit] close #1 end
[ok] #1.tb,"!contents? C$" print C$ wait or is this what you're after
'button #1.ok, "ok", [ok], UL, 100, 140, 100, 30 'textbox #1.tb 40, 35, 218,32 C$ = "This is the text I want to print to mainwin" Open "example" for text as #1 #1 "This is the code I want to print to the text window" print C$ wait
[quit] close #1 end
|
|
|
Post by DARKNIGHT on Dec 1, 2022 19:54:09 GMT -5
thanks. Was not aware that You could only print to a text window but not get output. 🤔 will give the textbox a go 😊
|
|
|
Post by xxgeek on Dec 1, 2022 20:05:55 GMT -5
You're welcome Jim, always happy to help when/if I can. Anymore questions don't be afraid to ask. Detail your problem, tell us what you want to accomplish, and post the code and the help will be better suited to your needs. We know you're new Jim, we were all new at one time. I still feel like I'm new at it.
|
|
|
Post by tsh73 on Dec 2, 2022 2:05:05 GMT -5
Well, you can Problem is this window cannot have buttons to tell program to start reading And I think it does not support trapping close event So program cannot detect if window is closing and do something (say, read text before it lost with closed window).
So using it for entering text seems rather pointless.
Open "example" for text as #1 Print #1, "Go and enter some text in this window here"
'program waits here input "Then you entered terxt in atext window, press Enter in a mainwin"; dummy$
'read textwindow contents Print #1,"!contents? C$" Print "Read from text window:" Print "----------------------" Print C$ Print "----------------------"
'don't forget to close window close #1 end
|
|
|
Post by tsh73 on Dec 2, 2022 3:39:02 GMT -5
Kind of form templete. Actually, *text* templete I have no idea if you have something like this in mind?
' Form created with the help of Freeform-J v.261006 ' Generated on Dec 02, 2022 at 10:51:25
nomainwin
WindowWidth = 1016 WindowHeight = 445
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
textbox #main.field1, 350, 36, 100, 25 textbox #main.val1, 470, 36, 100, 25 textbox #main.field2, 350, 71, 100, 25 textbox #main.field3, 350, 106, 100, 25 textbox #main.val2, 470, 71, 100, 25 textbox #main.val3, 470, 106, 100, 25 statictext #main.statictext7, "template", 26, 16, 144, 20 statictext #main.output, "output", 662, 16, 144, 20 statictext #main.statictext9, "fields", 374, 11, 80, 20 button #main.btnDo, "Substitute Fields", [btnDoClick], UL, 382, 151, 152, 25 statictext #main.statictext11, "values", 478, 11, 80, 20 texteditor #main.src, 22, 36, 304, 300 texteditor #main.dest, 590, 36, 304, 300 button #main.btnClr, "clearOutput", [btnClrClick], UL, 398, 211, 122, 25 menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "Filling the template" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
field1$="#user#" :val1$="John.S.Smith" field2$="#occasion#" :val2$="JustBASIC user fest 04 Dec 2022" field3$="#place#" :val3$="Discord JustBASIC cahnnel"
#main.field1, field1$ #main.field2, field2$ #main.field3, field3$ #main.val1, val1$ #main.val2, val2$ #main.val3, val3$
#main.src space$(5);"Hello ";field1$ #main.src "We are pleased to invite you to first ";field2$ #main.src "that will be held at ";field3$ ;" 24:00 GMT" #main.src "Don't forget to have fun, BYOB"
#main.btnDo "!setfocus"
wait
[quit.main] Close #main END
[btnDoClick] 'Perform action for the button named 'btnDo' 'gert template #main.src "!contents? txt$" 'get values #main.field1 "!contents? field1$" #main.field2 "!contents? field2$" #main.field3 "!contents? field3$" #main.val1 "!contents? val1$" #main.val2 "!contents? val2$" #main.val3 "!contents? val3$"
'substitute txt$=replstr$(txt$, field1$, val1$) txt$=replstr$(txt$, field2$, val2$) txt$=replstr$(txt$, field3$, val3$)
'output #main.dest "!cls" #main.dest txt$
wait
[btnClrClick] 'Perform action for the button named 'btnClr' #main.dest "!cls" wait
|
|