Page 1 of 3
Line Wrap
Posted: Fri Nov 19, 2010 2:12 pm
by John
00002 let cr$=chr$(13) : let lf$=chr$(10) : let crlf$=cr$&lf$
00010 open #1: 'srow=5,scol=5,name=tom,rows=10,cols=20,parent=none,relative',display,output
00020 print #1,fields '1,1,C': 'try'&cr$&'this'&lf$&'and this'&crlf$&'and this but really long stuff will auto wrap around and \n does nothing'
00030 input #1,fields '10,20,Cc 1': pause$
The above program does not force line breaks into the text... I'd like for it to... none of the things i tried worked, but is there another way or a trick that i can do to make semi generic text wrap to the next line?
Any suggestions?
Posted: Fri Nov 19, 2010 9:06 pm
by gtisdale
Short of calculating line lengths and breaking the text into segments and putting into an array there is no default way in BR to get line wrap.
Using outside aids you can however get line wrap and even spell check.
Specifically, David Blankenship shared a customized (striiped down) version of Atlantis at the Boston BRG conference that can do specifically this, pop up the thext in a text box and then save it to a display file whrer your BR program can pick it up and do whatever you want in br.
The attached program COMMENT.BR is one that I use to add a comment to a file for payroll processing. It uses a function in FNSNAP.dll and David's AWPLITE.exe program and spell check library.
FNGeorge
Posted: Fri Nov 19, 2010 10:43 pm
by Susan Smith
John, you might ask Gabriel about this. He does multi-line text boxes by using some trick that's been in BR for years. I don't know exactly what it is though. The restriction is that the box has to go all the way the entire width of the window, so if you want a narrower text box, you'd have to pop up a new window on top that is sized to the exact width that you want.
-- Susan
Posted: Sat Nov 20, 2010 9:46 am
by gtisdale
ok, If it's tricks you want then tricks you'll get.
PRINT FIELDS and INPUT FIELDS work differently. So what you want to do is a RINPUT FIELDS with a minimal WAIT
00002 LET CR$=CHR$(13) : LET LF$=CHR$(10) : LET CRLF$=CR$&LF$
00005 DIM A$*1000
00010 OPEN #1: 'srow=5,scol=5,name=tom,rows=10,cols=20,parent=none,relative',DISPLAY,OUTPUT
00020 LET A$='try'&CR$&'this'&LF$&'and this'&CRLF$&'and this but really long stuff will auto wrap around and \n does nothing'
00022 RINPUT #1,FIELDS "1,1,C "&STR$(LEN(A$)),WAIT=.01: A$ TIMEOUT 30
00030 INPUT #1,FIELDS '10,20,Cc 1': PAUSE$
The above change to your program should do it, but do a SREP$('\n',crlf$) to get rid of your imbedded \n
FNGeorge
Posted: Sat Nov 20, 2010 9:53 am
by gtisdale
ALso, to get rid of the ugly INPUT block at the bottom right corner:
1. Create a totally transparent png or jpg called BLANK.JPG
2. Stick it into a variable
3. Do a rinput fields with the target as the blank picture or use KSTAT$ to mask the field
dim b$*100
let b$='icons\blank.jpg'
00030 rinput #1, fields '10,20,P 1/1':b$
or
00030 if len(kstat$(1))>2 then stop else goto 30
FNGeorge
Posted: Mon Nov 22, 2010 7:34 pm
by Gabriel
BR does line wrapping automatically if you make a BR multi-line textbox. The secret is to make the textbox so big that it wraps around the screen.
So if the window that you're printing to is 80 characters wide, then print a C 240 to get a 3 line text box. You don't have to start it on the first column but it seems like its a good idea. And you don't have to make the text box an exact multiple of the child window (in this case an exact multiple of 80). If the "multiline" text box includes a half a row, BR will automatically round it up and make it the whole row.
You may have to make the textbox sunken. I achieve that using Print Fields by using the "S" attribute. That saves you from having to do the INPUT statement that George was talking about.
Gabriel
Posted: Tue Nov 30, 2010 12:59 pm
by Susan Smith
John,
I'm curious...how did you end up solving your line wrapping issue?
-- Susan
Posted: Tue Nov 30, 2010 1:20 pm
by John
I've been on vacation - so I haven't gotten back to that particular project yet (only got back monday) so I haven't tried the different things suggested yet... but I'll let you know when I do.
=)
Posted: Tue Dec 14, 2010 9:18 am
by John
Susan - the solution that works best for me is the one that George provided - very similar to what Gabriel does.
00002 LET CR$=CHR$(13) : LET LF$=CHR$(10) : LET CRLF$=CR$&LF$
00005 DIM A$*1000
00010 OPEN #1: 'srow=5,scol=5,name=tom,rows=10,cols=20,parent=none,relative',DISPLAY,OUTPUT
00020 LET A$='try'&CR$&'this'&LF$&'and this'&CRLF$&'and this but really long stuff will auto wrap around and \n does nothing'
00022 RINPUT #1,FIELDS "1,1,C "&STR$(LEN(A$)),WAIT=.01: A$ TIMEOUT 30
00030 INPUT #1,FIELDS '10,20,Cc 1': PAUSE$
That little program demonstrates it nicely.
=)
Thanks for all the feedback.
-John
Posted: Tue Dec 14, 2010 1:29 pm
by Gabriel
I love BR's secret multiline text boxes.
Now if there was only a way to do it without requiring a child window. The Child window makes it awkward or impossible to work with them in input fields statements with more then one field, because the multi-line textbox is forced to the entire width of the child window.
Gabriel
Posted: Tue Dec 14, 2010 1:33 pm
by Gabriel
So, John,
If your goal is to print something, then why are you using RINPUT FIELDS with a wait time of .01 in order to print it? Why not just use PRINT FIELDS?
(if you want the sunken appearance you can get it with the "S" attribute".)
Gabriel
Posted: Tue Dec 14, 2010 2:00 pm
by John
oh very good point... but a quick test shows that Print Fields and RInput Fields do not behave the same... I'm not done with this project yet (and once again) have moved another priority above it. So I still may change it around quite a bit before it's done.
One changes I did make was to change the wait from .01 to 0.
So the sample program now looks like:
00002 let cr$=chr$(13) : let lf$=chr$(10) : let crlf$=cr$&lf$
00005 dim a$*1000
00010 open #1: 'srow=5,scol=5,name=tom,rows=10,cols=20,parent=none,relative',display,output
00020 let a$='try'&cr$&'this'&lf$&'and this'&crlf$&'and this but really long stuff will auto wrap around and \n does nothing'
00022 rinput #1,fields "1,1,C "&str$(len(a$)),wait=0: a$ timeout 30
00030 input #1,fields '10,20,Cc 1': pause$
If you'd like to see the different output of print fields, try changing line 22 to:
00022 pr #1,fields "1,1,C "&str$(len(a$)): a$
-John
Posted: Tue Dec 14, 2010 2:11 pm
by Gabriel
So whats the difference between PRINT FIELDS with the "S" attribute and RINPUT FIELDS with "wait=0"?
Gabriel
Posted: Tue Dec 14, 2010 2:11 pm
by gtisdale
You can also try using CC and CR on line 22 i=of the RINPUT statement
FNGeorge
Posted: Tue Dec 14, 2010 3:02 pm
by gtisdale
There is a difference. See attached.