Line Wrap
Moderators: Susan Smith, admin, Gabriel
Line Wrap
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?
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?
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
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
- Attachments
-
- comment.br
- (3.48 KiB) Downloaded 443 times
-
- Posts: 717
- Joined: Sun Aug 10, 2008 4:24 am
- Location: Southern California
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
-- Susan
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
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
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
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
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
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
-
- Posts: 717
- Joined: Sun Aug 10, 2008 4:24 am
- Location: Southern California
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
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
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
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
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
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
There is a difference. See attached.
- Attachments
-
- fields.pdf
- Sample of difference between PRINT FIELDS and REINPUT FIELDS, wait=0
- (26.23 KiB) Downloaded 429 times