home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!darwin.sura.net!lhc!adm!news
- From: ZCCBJSB@eb0ub012.bitnet (Josep Sau)
- Newsgroups: comp.lang.pascal
- Subject: integer/string generic
- Message-ID: <35241@adm.brl.mil>
- Date: 27 Jan 93 11:03:06 GMT
- Sender: news@adm.brl.mil
- Lines: 47
-
-
-
- >from: "r. patel" <rpatel@massey.ac.nz>
- >subject: string and integer conversion (mac and pc) - help
- >date: 25 jan 93 20:25:22 gmt
- >to: info-pascal@brl.mil
- >
- >anyway i've got a pascal prog. on the mac which uses the sane library
- >functions int2str and str2int (ie converts a string to integer and
- >viceversa).
-
- >from: patrick pollet <ppollet@cismibm.univ-lyon1.fr>
- >subject: re: string and integer conversion (mac and pc) - help
- >date: 26 jan 93 08:25:59 gmt
- >to: info-pascal@brl.mil
- >
- > int2str should be changed to str()
- > str2int should be changed to val()
- > Caution: The parameters are differents and Str() and val() are
- > PROCEDURES whereas int2str() and str2int() are functions.
-
- I normally use these sub-programs and avoid raw STR or VAL
- in code. Perhaps you may profit from them:
-
- FUNCTION IntStr (lng :LONGINT) :STRING;
- (* LONGINT -> STRING,
- minimal integer representation. *)
- VAR
- s :STRING;
- i :INTEGER;
- BEGIN
- SYSTEM.STR(lng:0,s);
- IntStr := s;
- END;
-
- FUNCTION IntVal (s :STRING; VAR lng :LONGINT) :BOOLEAN;
- (* STRING -> LONGINT,
- returns TRUE if integer numeric conversion succeed *)
- VAR i :INTEGER;
- BEGIN
- SYSTEM.VAL(s,lng,i);
- IntVal := i = 0;
- END;
-
- -- Josep Sau: zccbjsb@eb0ub012.bitnet
- -- Library application programmer, Universitat de Barcelona.
- -- Enjoying TP/DOS. Using PLI/VM, REXX/VM. Suffering NATURAL/ADABAS.
-