Using ASC13 in translate

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using ASC13 in translate

Dr. Martin R. Hadam
 I'm close to getting desperate (hence this quest for help - even if it
may not be exactly the right spot to ask):

 I've been using the translate function to replace the "new line"
(ASC13) with a space successfully in several REXX programs for more
than a year. The code looks something like

 input = translate(input," ","
")

 and has been easily done using EPM (v6.03b) on OS/2. Sometimes, I got
an "error 6 - unmatched /* or quote" which went away after another save
of the program file.

 Now, all of a sudden, I don't get a new line after entering ASC13 and
the music note symbol instead. (I've reinstalled EPM and checked all
settings, no avail). Sometimes, the note symbol persists on saving,
sometimes, the code looks "right" like above - yet it just won't work
(error #6).

 Anyone knows what I'm doing wrong?? Since I'm processing highly
variable text input from email, this is a very useful function and I
could not think of a replacement..... and I need it really badly.

 Many thanks for any help in advance!

 Martin


 Martin R. Hadam
 Kinderklinik - Medizinische Hochschule
 D-30623 Hannover
 Germany
 Email: [hidden email]


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Using ASC13 in translate

xavier caballe
> I've been using the translate function to replace the "new line"
>(ASC13) with a space successfully in several REXX programs for more
>than a year. The code looks something like

May I suggest you a different approach? I use this code to remove the
nasty EOF characters that some OS/2 apps add at the end of
file:

/***********************************************************************/
/* FIXSQ - removes ASCII characters 26 and 28 from the end of a file   */
/* It will NOT modify your files in any other way (ie: codepages, etc) */
/* You will get a backup file called <filename>.backup                 */
/* Usage: FIXSQ <filename>                                             */
/***********************************************************************/
/* Show the hello screen */
do i=1 to 6; say sourceline(i); end
/* Get the filespc */
parse arg filespec
/* Hey! No parameters! */
if filespec == '' then exit

/* Get the REXX function for reading directories */
call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
/* Get the REXX function for deleting a file */
call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'

/* Get the list of files that honor the filespec */
call SysFileTree filespec, 'tabla', 'FO'

'@echo off'

/* Process the files one by one */
/* Loop to process every file found in the filespec */
do i=1 to tabla.0                
    /* Tell the user which file is being processed */
    say 'Processing file' tabla.i
    /* Open original file for reading */
    call stream tabla.i, 'C', 'OPEN READ'
    /* Open new file for output */
    call stream tabla.i||'.conv', 'C', 'OPEN WRITE'
    /* Loop to get chars one by one */
    do while chars(tabla.i) > 0
        /* Get one char from the input file */
        ch = charin(tabla.i)
        /* is it FS? skip it! */
        if c2d(ch) == 28 & chars(tabla.i) == 0 then iterate
          /* is it EOF? Skip it! */
        if c2d(ch) == 26 & chars(tabla.i) == 0 then iterate
          /* Write every char on the output file */
        call charout tabla.i||'.conv', ch
    end
    /* of character processing do-while loop */

    /* Close the input file */
    call stream tabla.i, 'C', 'CLOSE'
    /* Close the output file */
    call stream tabla.i||'.conv', 'C', 'CLOSE'

    /* Rename old file as backup, and new file as original */
    call SysFileDelete tabla.i||'.backup'
    'ren ' tabla.i || ' ' || filespec('NAME', tabla.i) || '.backup'
    'ren ' tabla.i || '.conv ' || filespec('NAME', tabla.i)
end /* of file-by-file do-while loop */

/* Final memory clean-up */
call RxFuncDrop 'SysFileDelete'
call RxFuncDrop 'SysFileTree'
exit





Xavi

---
It's nice to be important, but it is important to be nice!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>