dkl
Full Member
Posts: 234
|
Post by dkl on Aug 22, 2020 17:38:01 GMT -5
I am trying to achieve word wrap in a textbox (preferably) or else a texteditor.
Below is and example of what I have at the moment. It runs perfectly ok, but no word wrap. Of course, I could in this instance split up the 'Synopsis' in the programming, but that won't help within the main prgramme.
I took the command info from the stylebits wizard in LB workshop by Alyce's Restaurant website. I did find a few references to various other stylebits problems, but they didn't seen to help. I did see a reference to a texteditor programme also at the above mentioned website, but failed to find the programme.
Dim Synopsis$(10) Synopsis$(0)="A naive young man assumes a dead man's identity and finds himself embroiled in an underground world of power, violence, and chance where men gamble behind closed doors on the lives of other... See more '" index=0 Nomainwin WindowWidth = 450 WindowHeight = 200 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main3.textboxSyn, _ES_MULTILINE, 0, 0, 0 textbox #main3.textboxSyn, 10, 10, 410, 75
button #main3.ok, "Close", [quit.main],LL, 10, 10, 50,50
open "Synopsis" for window as #main3 print #main3, "font ms_sans_serif 10 Bold" print #main3, "trapclose [quit.main]"
print #main3.textboxSyn,Synopsis$(index) wait
[quit.main] close #main3 end Any suggestions on how to approach this? Thanks
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 22, 2020 17:51:14 GMT -5
SOLVED!!!!Stylebits #Main.textboxSyn, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0 Found the info at Alyce's Restaurant website
|
|
|
Post by Brandon Parker on Aug 23, 2020 13:43:21 GMT -5
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 23, 2020 23:24:42 GMT -5
I'm sorry Brandon, yes I did miss it, but having to add the chr$'s every x number of words word be messy and that why I wanted another way round the problem! The command below works really well through on all the random size array$'s.
Stylebits #Main.textboxSyn, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0 - cortesey of Alyce's restaurant and Janet Terra!
Many thanks for your help though.
Could I ask yet another question that i dont understand from the documentation.
The 'Trapclose' Command. I used to programme in Atari Basic many years ago! - That's going back a bit! - and if I put a 'trap' command at various problem points it would catch the error and stop the programme from crashing, thus keeping the programme running. A really good hack for bad programmer's - like myself!!
The 'trapclose' Command only seems to stop the programme and quit if there is an error. I've tried sending the programme to a different section eg [mainLoop], but it still just stops running. Is there any way that I keep the programme running without it crashing. Are there other Commands I can use?
Regards
|
|
|
Post by Brandon Parker on Aug 24, 2020 9:22:32 GMT -5
I can not see where the above gives you the word-wrapping that you are after, but if it is working the way you want then that is fine.
To answer your other question, the "TrapClose" command is issued to trap the "Close" event for the window. When issued for a window, the listed label or subroutine will be executed when that window is closed that way the programmer can tie up any lose ends or perform other housekeeping routines.
Here is how you would use it with a label.
NoMainWin
Open "Test TrapClose" For Window As #Main #Main "TrapClose [quit]" Wait
[quit] Close #Main End
Here is how you would use it with a subroutine. This is how I do it. Using handle variables (i.e. Close #handle$) is a handy way to reuse subroutines. Note that when using a subroutine, the "handle$" variable (or...any other string variable name) is required so that the handle of the window calling the subroutine can be passed in.
NoMainWin
Open "Test TrapClose" For Window As #Main #Main "TrapClose exitWindow" Wait
Sub exitWindow handle$ Close #handle$ End End Sub
{:0)
Brandon Parker
|
|
|
Post by Rod on Aug 24, 2020 9:28:40 GMT -5
You need to explore the ladybug icon. There are a variety of ways to run your program, step by step or to a breakpoint. Start the ladybug icon and explore the debugger's helpfile.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 24, 2020 18:17:09 GMT -5
Yes I use the debugger a LOT Rod!! I was just interested in the use of the 'Trapclose' Command. I don't always cotton on to the explanations used in the help files! They don't always help! But it's me NOT the explanation! I think it might the ONERROR Command I need to look into.
|
|
|
Post by Chris Iverson on Aug 24, 2020 19:48:32 GMT -5
I believe so.
ON ERROR is what lets you execute specific code(an error handler) if an error happens in your program.
TRAPCLOSE is used to notify you that the user has closed your window, and let you handle any cleanup needed properly(such as properly closing the window handle in LB, which does NOT happen automatically.)
|
|