TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Francois Thunus
from: David Noon
date: 1999-01-17 17:47:08
subject: Pl/I

In a message dated 01-15-99, Francois Thunus said to David Noon about
"Pl/I"

Hi Francois,

FT>so much for not reading completely the problem before answering :-)

>----- Begin -----

FT>function UpStr(instring:string):string;
FT> var
FT>  i    : byte;
FT>begin
FT> for i:=1 to length(instring) do
FT>      instring[i]:=upcase(instring[i]);
FT> UpStr:=instring;
FT>end;

>-----  End  -----

You still need ParamCount instances of ParamStr() calls to obtain the
"bleeding chunks" of your original parameter string and a WRITELN() call to
display it.

My version:

============================ TOUPPER.PAS ===================================
PROGRAM toupper;

USES System; { Needed for ParamCount and ParamStr(). }

FUNCTION UpStr(CONST Instring : STRING) : STRING;
VAR
  p : INTEGER;
BEGIN
  RESULT[0] := Instring[0]; { Copy length byte without translation }
  FOR p :=  1 TO LENGTH(Instring) DO
    RESULT[p] := Upcase(Instring[p])
END;

VAR
  i : INTEGER;
  ParmStr : STRING;
BEGIN
  IF ParamCount = 0 THEN
    ParmStr := ''
  ELSE
  BEGIN
    ParmStr := ParamStr(1);
    { We will _guess_ that each piece was separated by a single blank }
    FOR i := 2 TO ParamCount DO
      ParmStr := ParmStr + ' ' + ParamStr(i)
  END;
  WRITELN(UpStr(ParmStr))
END.
============================================================================

Now, how does this compare to Murray's complete program? His contained
exactly 1 line of executable code, which did all of the above.

 DN> lost the spacing information! Since, under OS/2, filenames can contain
 DN> spaces and the spaces are significant

FT>mmmm. I'm not sure I understand the probelm. what is 
FT>preventing you from using temp variable or to treat each 
FT>chunk separately and then piece it back
FT>together ?

You don't know how many spaces were between each of the pieces [which is why
I underscored the word _guess_ in my program's comments] and, as I said
above, spaces are significant.

Regards

Dave

___
 * MR/2 2.25 #353 * If Windows is User-Friendly, why do you need to read a
678 pg. manual?

--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4)
SEEN-BY: 396/1 632/0 371 633/260 262 267 270 371 635/444 506 728 639/252
SEEN-BY: 670/218
@PATH: 440/4 255/1 251/25 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™.