TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: DAVID NOON
from: IVAN TODOROSKI
date: 1999-01-15 04:53:00
subject: Pl/I

On Wednesday, 13 January 1999,
     DAVID NOON wrote to FRANCOIS THUNUS about Pl/I

 DN> Hi Francois,

 ML>> *process langlvl(saa2), limits(extname(31)), libs, not('^');
 ML>>  toupper: proc(infile) options (main noexecops);
 ML>>     dcl infile char(100) var;
 ML>>     dcl translate builtin;
 ML>>     dcl (From value('abcdefghijklmnopqrstuvwxyz'),
 ML>>          To value('ABCDEFGHIJKLMNOPQRSTUVWXYZ')) char(26);
 ML>>     display (translate(infile,to,from));
 ML>>   end toupper;

 ML>>     I leave it as an exercise for the reader to write the equivalent in
 ML>> Pascal :-).

 DN> FT>Borland Pascal:
 DN> FT>upcase();

 DN> Not quite correct. The upcase() function only handles one
 DN> character, just like the C toupper() function. Murray's program
 DN> translates the entire string in a single function call.

 DN> You are at least a FOR-loop short of a program there.

 DN> FT>:-)

 DN> :-(

 DN> It gets worse. The only way to get the parameter string without
 DN> resorting to raw API calls is Paramstr(i), where each token of the
 DN> parameter string has been parsed out. You have to put them back
 DN> together again and you have lost the spacing information! Since,
 DN> under OS/2, filenames can contain spaces and the spaces are
 DN> significant (Murray's parameter is named 'infile', so I would
 DN> infer it is the filename of an input file) you will not be able to
 DN> get back to your original data in Pascal.

  I agree with your point. If the filename had a couple consecutive
  spaces in it, then there would be no way to reconstruct it from the
  ParamStr() fragments. I tried even enclosing the parameter in quotes
  and Turbo Pascal still split them at the white-space :( Don't know if
  any OS/2 native Pascal compilers handles this correctly...

  I also see some similarities between PL/I and REXX you mentioned in
  that earlier message about PL/I. The designers of REXX practically
  ripped off the translate() function from PL/I :)

  But I was wondering if there is some PL/I equivalent to REXX's
  xrange(), so that one could avoid typing the translation tables by
  hand?

  In REXX it would simply be:

    say translate(infile, xrange("A","Z"),
xrange("a","z"))

  ignoring for the moment the fact that just translate(infile) without
  the translation tables would uppercase infile by default :)

  Anyway, even if there isn't, I suppose it would be trivial to write
  such a function in PL/I...

  And one more thing, does PL/I support variable numbers of parameteres
  like in REXX?

                                                            - Ivan -

.!. Sure hope this works. Last time I pushed this butto       NO CARRIER
--- Terminate 5.00/Pro [OS/2]
 þ TerMail/QWK þ  
* Origin: GET ALL YOUR FIDO HERE! telnet://bbs.docsplace.org (1:3603/140)
SEEN-BY: 396/1 632/0 371 633/260 262 267 270 371 635/444 506 728 639/252
SEEN-BY: 670/218
@PATH: 3603/140 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.