Line Wrap

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

Did you forget the "S" parameter?

I just tried it and I get different results from you.

My program is

Code: Select all

00002 LET CR$=CHR$(13) : LET LF$=CHR$(10) : LET CRLF$=CR$&LF$
00010 OPEN #1: 'srow=5,scol=5,rows=10,cols=20',DISPLAY,OUTPUT 
00020 PRINT #1,FIELDS '1,1,C,S': '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$
And I get the proper line wraps.

Gabriel

PS. The "S" parameter makes PRINT fields work like RINPUT FIELDS with no wait.
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

Yes, I did omit the "S".
However, with the "S" the result is not quite the same. The text appears on the window with a white background rather than the inactive grey of the RINPUT.
If you couple the "S" with a "P" to protect the fields (,SP) then you get the inactive color back and they are the same.

I notice that with the wrapping the text actually takes up more space than BR calculates so either the forst line (in RINPUR) or the last line (in PRINT) is not viewable and needs to be scrolled to view.

A remedy to this is to specify the length of the field to be the length of the displayed string and then add a number to it. In the case of the example that we have been working with from John, adding 10 works just great.

00024 PRINT #1,FIELDS "1,1,C "&STR$(LEN(A$)+10)&",SP": A$

Thanks for sharing the concept of the "S" attribute Gabriel!

FNGeorge
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

I suppose in a way I did forget the S attribute. I didn't really want my text to look sunken - because my ultimate goal here is more or less a messagebox replacement - but it sure does make a difference on how the fields wrap. Without it - they don't. :P

Thanks for that tip - Apparently the wrapping has something to do with sinking. Perhaps I'll just have to live with that sunken look.

I would really like for the user to be able to highlight and copy and paste text from their messages - is there a way that you know of which i can let them highlight and copy, but still prevent them from changing the text?

-john
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

John:

Since you are looking for a messaggebox replacement, have you looked at the FNWAIT... functions in FNSNAP?

They are designed to work as a family and include

FNWAITWIN

Code: Select all

FNWAITWIN(MESSAGE$*1000;TITLE$*50,BUTTONS$*100,DEFAULT,BKGRND$*100,WAITTIME)
Displays a message box with a message and continues returning the file number of the wait widow as the result. Can be used for "Updating files, Please wait" etc. Optionnally buttons can be added which changes the nature of the box, the function then waits for user response, eithe a letter or mouse click and returns the button number pressed.

FNWAITMSG

Code: Select all

FNWAITMSG(MESSAGE$*1000)
Displays a different tex in the already open wait window such as the file name being updated or other temporary message during processing

FNWAITBAR

Code: Select all

FNWAITBAR(TOTBAR,CURBAR)
Displays a progress bar based on the total and current numbers passed to the function. Up date only happens when a noticeable change occurs in the percentage (1/20th)
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

I really was asking George if he forgot the S attribute in his example because I tried it myself and got different results then he did.

But yeah, the "S" makes all the difference.


You're gonna get a sunken appearance if you use RINPUT fields with no wait, and you're gonna get a sunken appearance if you use PRINT fields. No difference.

The only way to have automatic line wrapping done in BR is with a sunken multi-line field.


So the P doesn't allow them to copy and paste changes?

Anyway, if you want them to be able to copy and paste text but not make changes, then:

1) Ignore the changes they make to the text.
2) Trap any changes they make using your AEX attributes and whatever you do there.
3) Reprint the original text to the screen after the input finishes so that it doesn't look like they changed it.

Gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

Gabriel - P attribute does not allow copying of text. And AEX allows all kinds of changes to be made to the text. I don't think there is anyway in BR! to make a multiline text box that users can read and copy but not edit... perhaps I'll just make a little [copy all] button. yeah.

-John
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

Sure, just send it to the clipboard and they can then paste it into another spot, editing it at that spot or not as your prgram will allow.

if fkey=xxx then setenv("CLIPBOARD",a$)

let b$(inf:inf)=env$("CLIPBOARD")
or ctrl-V
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

A copy button! Perfect!

The other problem with Editable multi-line text boxes in BR is there is no way for the user to insert Carriage Returns into them. Pressing enter just interrupts the input fields statement.

Does anyone know a solution for that one?

I wonder if I could remap the enter key to something else and do my own enter key processing: (if curfld = a multiline textbox then append a CR to the text inside, and go back to the input statement... hmm)...

Gabriel
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

In some windows programs like frontpage, excel and word - Enter will make a new paragraph or take you outta the cell, but Ctrl+Enter is used to add a line break... So if you can capture a Ctrl+Enter it might be a relatively intuitive key to catch.
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

It's not a perfect soliution, but I use \n or \N and srep$ it with CRLF$ when I transfer it to a file, also srep$(A$,crlf$,"\n") before displaying it in a field. Not perfect, but works for what I'm doing.

I also use David's Atlantis Lite to spell check these textboxes. Can not display as a prt of an input mat, but can pop-up to use it in a no-parent when the field is accessed.

Code: Select all

00199 LIBRARY ENV$("PD")&"vol002\fnsnap.dll": FNGETHANDLE,FNOK,FNAWPLITE$
01000 EXECUTE "PROC *:vol002\tt"
01010 IF EXISTS("prdatc\comment.txt")=2 THEN !:
      OPEN #(COMMENT:=FNGETHANDLE): "Name=prdatc\comment.txt,recl=2000",DISPLAY,INPUT  !:
      ELSE !:
      OPEN #(COMMENT:=FNGETHANDLE): "Name=prdatc\comment.txt,recl=2000,replace",DISPLAY,OUTPUT  !:
      PRINT #COMMENT: " " : CLOSE #COMMENT: : LET COMMENT=0 : GOTO 1010
01020 PRINT NEWPAGE
01030 DIM A$(1)*2000,A$*2000,INWRK$(1)*60
01035 LET A=0
01040 COMMENT1: LINPUT #COMMENT: A$ EOF COMMENT2
01050 LET A+=1 !:
      MAT A$(A) : MAT INWRK$(A) !:
      LET A$(A)=A$ : LET INWRK$(A)=STR$(A*3)&",1,180/V 2000,X[D]"
01060 GOTO COMMENT1
01070 COMMENT2: ! 
01071 LET A$(1)=FNAWPLITE$("Comment",10,40,1000,"vol002\awplite.txt",A$(1))
01072 REM RINPUT FIELDS MAT INWRK$: MAT A$ !:                                                       LET AF=CURFLD !:                                                                          LET AK=FKEY
01075 GOTO COMMENT3
01080 IF NOT AK AND AF=A AND FNOK THEN GOTO COMMENT3
01090 IF NOT AK THEN LET CURFLD(AF+1,AK) ELSE LET CURFLD(AF,AK)
01100 GOTO COMMENT2
01110 COMMENT3: CLOSE #COMMENT,FREE: 
01120 OPEN #COMMENT: "name=prdatc\comment.txt,recl=2000,replace",DISPLAY,OUTPUT 
01130 FOR A=1 TO UDIM(A$)
01140 PRINT #COMMENT: A$(A)
01150 NEXT A
01160 CLOSE #COMMENT: 
01170 EOJ: LET MENU_NAME$=ENV$("menu_name") !:
      LET MENU_SEQ$=ENV$("MENU_SEQ") !:
      CHAIN ENV$("PD")&"workmenu.br",MENU_NAME$,MENU_SEQ$
Above is a program that I use to add a comment field to a processing checklist I use for payrolls.

Below is the function that is in FNSNAP to dp the substitution, load the spell checker etc.

Code: Select all

04900 DEF LIBRARY FNAWPLITE$*1000(CAPTION$*100,AROWS,ACOLS,ALEN,RESULTS$*100,AWTEXT$*1000) !:
      ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³ Caption  caption in the AWP window during spellcheck         ³!:
      ! ³ AROWS  the approx number of rows for the spell check window  ³!:
      ! ³ ACOLS  the approc number of columns for the spell check win  ³!:
      ! ³ ALEN   the allowed length of the returned phrase             ³!:
      ! ³ RESULTS$ file name for the transfer file                     ³!:
      ! ³ AWTEXT$ the text to be spell checked by AWPLite              ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
04902 LIBRARY ENV$("PD")&"vol002\fnsnap.dll": FNGETHANDLE
04903 EXECUTE "proc=*:vol002\tt"
04904 LET FNAWPLITE$=AWTEXT$
04905 OPEN #(AWP:=FNGETHANDLE): "name="&ENV$("PD")&"vol002\awp"&SESSION$&".txt,replace",DISPLAY,OUTPUT 
04910 DIM AWP$*100,AWT$*1000
04915 ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³  Open the parameters file for AWPlite                        ³!:
      ! ³                                                              ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
04920 LET AWP$=OS_FILENAME$(FILE$(AWP))
04925 PRINT #AWP: "[Params]"
04930 PRINT #AWP: "Caption="&CAPTION$
04935 PRINT #AWP: "ClientWidth="&STR$(ACOLS*12)
04940 PRINT #AWP: "ClientHeight="&STR$(AROWS*20)
04945 PRINT #AWP: "MaxChars="&STR$(ALEN)
04950 PRINT #AWP: "Font Face=Arial"
04955 PRINT #AWP: "Font Size=11"
04960 PRINT #AWP: "SaveBtn_Caption=Save"
04965 PRINT #AWP: "CancelBtn_Caption=Cancel"
04970 PRINT #AWP: "ResultFile="&OS_FILENAME$(ENV$("PD")&"vol002\awr"&SESSION$)
04975 CLOSE #AWP: 
04980 ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³ Create the transfer file for data to be used by AWPlite      ³!:
      ! ³                                                              ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
04985 OPEN #(AWT:=FNGETHANDLE(AWP)): "name="&ENV$("PD")&"vol002\awt"&SESSION$&".txt,recl="&STR$(ALEN)&",replace",DISPLAY,OUTPUT 
04990  PRINT #AWT: SREP$(AWTEXT$,"\n",CRLF$)
04995 LET AWT$=OS_FILENAME$(FILE$(AWT))
05000 CLOSE #AWT: 
05005 ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³ Load and run the AWPlite program against the text            ³!:
      ! ³                                                              ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
05010 EXECUTE "sys -w "&OS_FILENAME$(ENV$("PD")&"vol002\awplite.exe")&" "&AWP$&" "&AWT$
05015 ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³ Check to see if AWPlite has created the RESULTS file that    ³!:
      ! ³ indicaetes that spell check has completed or aborted         ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
05020 IF EXISTS(ENV$("PD")&"vol002\awr"&SESSION$)=2 THEN GOTO 5025 ELSE LET SLEEP(1) : GOTO 5020
05025 OPEN #(AWR:=FNGETHANDLE(AWT)): "name="&ENV$("PD")&"vol002\awr"&SESSION$,DISPLAY,INPUT 
05030 LINPUT #AWR: RESULT$
05035 CLOSE #AWP: 
05040 EXECUTE "free "&ENV$("PD")&"vol002\awr"&SESSION$
05045 ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!:
      ! ³ If the user has SAVED the checked text then replace the      ³!:
      ! ³ original, if CANCEL then leave the original                  ³!:
      ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
05050 IF TRIM$(UPRC$(RESULT$))="SAVE" THEN 
05055   OPEN #(AWT:=FNGETHANDLE(AWT)): "name="&ENV$("PD")&"vol002\awt"&SESSION$&".txt",DISPLAY,INPUT 
05056   LET AWX=0
05060   LINPUT #AWT: AWTEXT$ EOF 5070 !:
        LET AWX+=1
05065   IF AWX>1 THEN LET AWT$(INF:INF)="\n"&AWTEXT$ ELSE LET AWT$=AWTEXT$
05067   GOTO 5060
05070   CLOSE #AWT: 
05072   LET FNAWPLITE$=AWT$
05075 END IF 
05080 FNEND 
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

I almost have it working. Pressing enter in the middle of a multiline textbox inserts a carriage return in the right place. The only problem is, after inserting the carriage return, when i come back to the input field, the entire text is selected and the curser is moved to the end of the entered text.

This has the result that any further typing wipes out the entered text and that would be confusing to the end user indeed.

Does anyone know a way to position the curser where I want it and to specify what text is selected?

Code: Select all

00100     dim X$*100, Y$*20
00110  !
00120     let Width=20
00130     let Height=4
00140  !
00150     let Cr$=Chr$(13) : let Lf$=Chr$(10) : let Crlf$=Cr$&Lf$
00160     open #1: 'srow=5,scol=5,rows=10,cols='&Str$(Width),display,output
00170  !
00180     do
00190        rinput #1,fields '1,1,C '&Str$(Width*Height)&',S;10,1,C 20': X$,Y$
00200  !
00210        if Curfld =1 then
00220           let Position=(((Currow-1)*Width)+Curcol)
00230           let X$(Position:Position-1)=Crlf$
00240           let X$=Trim$(X$)
00250        end if
00260     loop Until Fkey=99
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

We used to be able to specify the cursor position within a field by stating the p[osition as a number in the control attribute of the field. The following is from the Wiki:

The following example shows how the cursor can be positioned on the third character of a date field. Since only the middle field of a date (mmddyy format) is typically changed, this feature saves time for the operator.

Code: Select all

01100 RINPUT FIELDS "10,40,n 6,u3": SHIPDATE
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

Thats brilliant, George!! Thank you. We're getting pretty close now..

Pressing Enter correctly inserts a CRLF in the correct location and moves the curser to the correct location as well, both in the middle and at the end of a line.

The only problem is, if the curser is at the end of a line and you press enter, the curser does not appear to move. If you continue typing, the curser jumps down to the next line and writes from there. It would be a little confusing to a user who may hit enter several times and wonder why the curser isn't moving, but its a heck of a lot better then anything we've had before now.

Copy and paste the program into MyEdit and give it a try. You can even change the size of the multi-line text box by changing the parameters at the top.

Any ideas for how to fix the curser problem??

Here's what I've tried so far: I can get the curser to move to the next line down by adding an additional character, such as a "." after the crlf$, and placing the curser between the crlf$ and the ".". That works, but of course the document fills up with dots. To see it, unremark the comment at the end of line 240 below.

So then I tried with an invisible character but the problem is the characters that are invisible in standard ASCII are not the same characters that are invisible in gui mode.. The invisible characters in gui mode depend on your font and they're different for every font. Chr$(1), invisible in the font I was using, worked exactly half the time.

Now all I have to do is get the up and down arrows working and we're in business!!! :)

Gabriel

Code: Select all

00100     dim X$*1000, Y$*20
00110  !
00120     let Width=60
00130     let Height=8
00140     let position=-1 ! First time around, start at beginning
00150  !
00160     let Cr$=Chr$(13) : let Lf$=Chr$(10) : let Crlf$=Cr$&Lf$
00170     open #1: 'srow=5,scol=5,rows=10,cols='&Str$(Width),display,output
00180  !
00190     do
00200        rinput #1,fields '1,1,V '&Str$(Width*Height)&','&str$(position+2)&';10,1,V 20': x$,Y$
00210  !
00220        if Curfld=1 then ! If we're in a multi-line textbox field
00230           let Position=(((Currow-1)*Width)+Curcol) ! find the position
00240           let X$(Position:Position-1)=Crlf$   !  &"."
00250        end if
00260  !
00270     loop Until Fkey=99
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

When I run your program I only get 1,1 as currow,curcol. Not the position within the textbox of the cursor.

Running the test in BR4.2 g+.

As a result all CRLF$s are prepended to the text string.
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

Hmm.. I'm testing in BR 4.1 and it works the way I describe.

That's sucks that it doesn't work in 4.2. I hate when they change things on us. My code is supposed to work equally well no matter what version of BR you're running, because its written for BR developers instead of end users. And its such a mess to keep having to test which version of BR we're in and do things in different ways for every version.

Do you have a copy of 4.1 you could throw in there to test with?

Do you know how to read CurRow and CurCol in BR 4.2 if they don't work the way they do in 4.1? (I'll eventually have to make my routine work in both versions.)

Gabriel
Post Reply