large blobs of text in source files

Developers
2010-01-01
2012-08-14
  • Stéphane Charette

    I have some scripts that generate a lot of text output. Parts of this output
    consists of many consecutive source lines with nothing more than a call to:
    say '...some static text...'

    The problem is the static text it outputs in those locations contain many
    single quotes and double quotes, meaning I end up having to escape characters
    all over the place. Isn't there a way to easily define a multi-line blob of
    text within a .rexx source file?

    Google hasn't helped me find this, so at the moment I'm guessing I'm
    incorrectly remembering this from some other language.

    Thanks for any help,

    Stéphane Charette

     
  • Jeremy C B Nicoll

    You could work around the problem by one of

    a) putting the text into separate files, and then using whatever your OS's

    way of copying a file to standard output is, for example

    "type" filename

    b) if your text is plain language you could define it all (say) in single

    quotes. Replace every actual single-quote inside the text by a

    backward single quote (or any other weird character which will

    never crop up for real in the text). Then instead of

    say '...some text...'

    have

    say translate('...some text...',"'","`")

    Although there's overhead, in doing so, I'd rather have

    call s 'This is a piece of text with a " and a ` in it.'

    and have a defined s procedure

    s: procedure ; parse arg text ; say translate(text,"'","`") ; return

     
  • jfaucher

    jfaucher - 2010-01-04

    Maybe you can retrieve the text with sourceline() ?

    call HereText

    --By using -- comments instead of / ... / then we can freely embed */ characters
    --Special characters should be supported : " ' ? ! - éèçà
    --You may have a problem of characters encoding... For example, the french accents
    --won't be displayed correctly in a DOS shell.
    call DisplayHereText

    return

    HereText:

    procedure expose SIGL HereText.

    i = 0

    line = SIGL + 1

    do forever

    sourceline = sourceline(line)

    if (left(sourceline, 2)) <> "--" then leave

    i = i + 1

    line = line + 1

    HereText.i = substr(sourceline, 3)

    end

    HereText.0 = i

    return

    DisplayHereText:

    procedure expose HereText.

    do i=1 to HereText.0

    say HereText.i

    end

    return

     

Log in to post a comment.