Mike, While I don't have time to work on a solution. Several ideas occur. As some on mentioned you may need to strip out the CR & LF. That seems to be the case from the output shown below. The other is to use the following function to find the space that indicates a word break.
(SLOCP(TextNoteVarcharValue,string,occurrence)) Locates the exact position of a given string and occurrence in a TEXT, NOTE or VARCHAR value, returning the position if the string is found, 0 if it is not found. Using -1 as the third parameter will return the LAST occurrence. This would allow you to have a moving window into the text/note/varchar variable. I would be interested in seeing your final code as I might have a use for it in one of my applications where I am breaking in the middle of a word. The app would look much nicer if a could break on words instead of in the middle of words. Jim Bentley American Celiac Society [email protected] tel: 1-504-737-3293 ----- Original Message ---- From: Mike Byerley <[email protected]> To: RBASE-L Mailing List <[email protected]> Sent: Thu, July 8, 2010 4:19:50 PM Subject: [RBASE-L] - re: inserting text in ascii file. Send me an example text file (direct off list) if you can. Also, show me a dozen or so lines of the code you are using to collect the file contents into a variable. Also show any pertenant variable declarations. ----- Original Message ----- From: "Luc Delcoigne" <[email protected]> To: "RBASE-L Mailing List" <[email protected]> Sent: Thursday, July 08, 2010 5:06 PM Subject: [RBASE-L] - re: inserting text in ascii file. > Mike, > > i tried your code and I got this : > > " > normale koepelstanden. vrije laterale en dorsale sinussen, > zonder tekens > van pleuravocht. normale hartgrootte. scherpe aflijning van de hili. > norm > ale breedte van het bovenste mediastinum. mediane positie van de trachea. > > > normale aeratie van de longvelden. homogene aeratie van de longvelden, > z > onder confluerende infiltraten noch verdachte opaciteiten. > > normale botst > ructuren. > > " > > Never mind the dutch language, > The line-length is OK and is set to 75. > but as you see I still get some words that are chopped. > How could I solve this ? > > Luc > -------------------------------------------------- > From: "Mike Byerley" <[email protected]> > Sent: Thursday, July 08, 2010 10:41 PM > To: "RBASE-L Mailing List" <[email protected]> > Subject: [RBASE-L] - re: inserting text in ascii file. > >> It looks like I wrote it eight years ago to solve a different problem. It >> just >>happens it will likely work for yours. You can change the wrap variable to >>any >>number and it will insert a CrLf at that location. >> >> I can think of another solution to the problem that might be a little >> quicker. >>Take the variable that contains the file contents, strip out all of the CrLf, >>then process from the beginning using some of the logic in the code I sent, >>the >>difference being instead of concantenating Notes on the fly, you would add >>completed lines to a variable user defined ListBox and when you are done, you >>can use the ListBox's Save_To_File method. >> >> If the length of the file contents isn't too long, there might not be such >>distinguishable difference, so what I sent would probably work without >>reinventing it all over again. >> >> >> ----- Original Message ----- From: "Luc Delcoigne" <[email protected]> >> To: "RBASE-L Mailing List" <[email protected]> >> Sent: Thursday, July 08, 2010 4:30 PM >> Subject: [RBASE-L] - re: inserting text in ascii file. >> >> >>> Mike, >>> >>> This is more than just a forum. This is really a place where people help >>>people. >>> >>> I must say that R:base has been so far a heart-warming experience. >>> >>> Thank you. >>> I will try the code immediately. >>> >>> Too hot to go to sleep over here. >>> >>> Luc Delcoigne >>> >>> -------------------------------------------------- >>> From: "Mike Byerley" <[email protected]> >>> Sent: Thursday, July 08, 2010 10:25 PM >>> To: "RBASE-L Mailing List" <[email protected]> >>> Subject: [RBASE-L] - re: inserting text in ascii file. >>> >>>> Is the problem that after you have it (the file) converted to a Text >>>> variable >>>>(is it TEXT or VARCHAR), that the word wrap is beyond 75 characters? >>>> >>>> If it is, I have some old rbase code that wraps text at a designated >>>> maximum >>>>width. Also, after you get the DLL, you will be able to process text files >>>>any >>>>way that is permitted within the VBScript Language. >>>> >>>> The RBASE CODE: >>>> >>>> {begin code} >>>> LABEL bgprog >>>> >>>> >>>> SET VAR vnote NOTE = (.vVariableOfMyTextFileContents) >>>> >>>> CLEAR VAR v1,v2,v3,v4,v5,v6,v7,v8 >>>> SET VAR vstrtmp NOTE >>>> SET VAR vgetlen INTEGER >>>> SET VAR vgettext TEXT >>>> SET VAR vstrlen INTEGER >>>> --the wrap location >>>> >>>> SET VAR vwrap INTEGER = 75 >>>> SET VAR vcrlf = ((CHAR(13))+(CHAR(10))) >>>> SET VAR vstrlen = (SLEN(.vnote)) >>>> WHILE vstrlen > 0 THEN >>>> SET VAR vsloc = .vwrap >>>> --test for location of space at wrap point >>>> IF (SGET(.vnote,1,.vwrap)) <> ' ' THEN >>>> -- loop backwards till find set var vgetlen = .vsloc >>>> WHILE (SGET(.vnote,1,.vsloc)) <> ' ' THEN >>>> IF (SLEN(.vnote)) <= .vsloc THEN >>>> SET VAR vsloc = (SLEN(.vnote)) >>>> SET VAR vgetlen = (SLEN(.vnote)) >>>> ELSE >>>> SET VAR vsloc = (.vsloc - 1) >>>> SET VAR vgetlen = .vsloc >>>> ENDIF >>>> ENDWHILE >>>> SET VAR vgettext = (SGET(.vnote,.vgetlen,1)) >>>> SET VAR vgettext = (LJS(.vgettext,.vgetlen)) >>>> SET VAR vgettext = (STRIM(.vgettext)) >>>> SET VAR vstrtmp = (.vstrtmp + .vgettext + .vcrlf) >>>> SET VAR vstrlen = (.vstrlen - .vgetlen) >>>> IF vstrlen < 0 THEN >>>> SET VAR vstrlen = (SLEN(.vnote)) >>>> ENDIF >>>> SET VAR vnote = (SGET(.vnote,.vstrlen, (.vgetlen + 1))) >>>> ELSE >>>> SET VAR vgettext = (SGET(.vnote,.vwrap,1)) >>>> SET VAR vgettext = (LJS(.vgettext,.vwrap)) >>>> SET VAR vgettext = (STRIM(.vgettext)) >>>> SET VAR vstrtmp = (.vstrtmp + .vgettext + .vcrlf) >>>> SET VAR vstrlen = (.vstrlen - .vwrap) >>>> IF vstrlen < 0 THEN >>>> SET VAR vstrlen = (SLEN(.vnote)) >>>> ENDIF >>>> SET VAR vnote = (SGET(.vnote, .vstrlen, (.vwrap + 1))) >>>> ENDIF >>>> ENDWHILE >>>> SET VAR vnote = (SRPL(.vstrtmp,' ', ' ',0)) >>>> LABEL ndproc >>>> show var vnote=.vwrap at 5 20 >>>> CLEAR VAR vcrlf,vgetlen,vgettext,vsloc,vstrlen,vstrtmp,vwrap >>>> RETURN >>>> >>>> {end code} >>>> >>>> ----- Original Message ----- From: "Luc Delcoigne" ><[email protected]> >>>> To: "RBASE-L Mailing List" <[email protected]> >>>> Sent: Thursday, July 08, 2010 4:09 PM >>>> Subject: [RBASE-L] - re: inserting text in ascii file. >>>> >>>> >>>> Hi all, >>>> >>>> I've been sweating all day long on this problem. >>>> >>>> In a ascii file I have to insert the contents of a rtf- blob. >>>> With the RRTFtoTxt pluging I could convert the it to a text variable. >>>> >>>> Now I can insert the text variable in my file. >>>> >>>> BUT the lines of the inserted text cannot be longer than 75 characters. >>>> >>>> This is an essential part of my application. >>>> >>>> Without this I could be forced to stick with Access where I can manipulate >>>> the >>>>file with the Wordobj....and I love R:base... >>>> >>>> Any ideas ?? >>>> Grtz >>>> >>>> Luc Delcoigne >>>> >>> >>> >> >> > >

