Article View: comp.lang.pascal.borland
Article #193Re: String to Integer Problem
From: Dr John Stockton
Date: Thu, 23 Mar 2000 00:00
Date: Thu, 23 Mar 2000 00:00
58 lines
3665 bytes
3665 bytes
JRS: In article <953775438.4306.0.nnrp-09.9e98e529@news.demon.co.uk> of
Thu, 23 Mar 2000 01:37:15 seen in news:borland.public.turbopascal, Runes
<okuk@yahoo.com> wrote:
>Can someone please help me, this problem is kinda urgent.
>
>What im doing is storing numerical digits in a string and then using the val
>function to convert the values held in the string to integer values. The
>integer values act as primary key to records held on a stock file.
>
>My problem is this, say i enter '10 , 22 or 33' into the string it always
>comes out as '1, 2 or 3' so I am only able to call the first 9 items held in
>my stock file. Any ideas on whats going wrong?
The string may not contain what you think it contains.
Call the string S for the moment : you have Val(S, X, J) where X is the
result and J the error indicator.
Make your code say
Writeln ;
Write(' S = "', S, '" ') ;
Val(S, X, J) ;
Writeln(' -> X = "', X, '", J = "', J, '".') ;
Then examine the whole output line, in conjunction with Manual &/or Help
for Val - and if you're still stuck, post EXACTLY the minimum necessary
code and the output. It may be that only after seeing, exactly, the
minimum needed to demonstrate your difficulty are we able to understand
it.
I'm reminded of a colleague who I was advising by telephone; he had put
EXEC(...) in a TP program, getting the obvious run-time error. I said
"Put open-twiddly-bracket dollar M space 10000 comma nought comma nought
close-bracket" at the very beginning - he did, and reported failure to
compile. I repeated, and he checked : he said that he'd put what I
said. It was only after sharing the file, so that I could edit and
compile it myself, that I saw that it now read :
open {$M 10000,0,0}
program ...
You have posted to borland.p.t, comp.l.p.b, comp.l.p.m, injecting at the
Demon server. News:borland.* newsgroups should (according to Borland)
be read/written using only their own server, forums.borland.com, and
they don't like cross-posts; but they won't see your article. Therefore
I have re-ordered the newsgroups line. Read the c.l.p.b mFAQ, via Sig
below.
You should also say, when posting to c.l.p.m, say whose version of
Pascal you are using; but, as you post to b.p.t & c.l.p.b, we presume
Turbo/Borland Pascal, which is off-topic in c.l.p.m.
--
� John Stockton, Surrey, UK. jrs@merlyn.demon.co.uk Turnpike v4.00 MIME. �
<URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
<URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.
Technical Details
Message-ID:
<Dm3clHAsyf24Ewbj@merlyn.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<953775438.4306.0.nnrp-09.9e98e529@news.demon.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10261c,ef9c8329edc525dd X-Google-Attributes: gid10261c,public X-Google-Thread: 108ebd,ef9c8329edc525dd X-Google-Attributes: gid108ebd,public X-Google-Thread: 111659,ef9c8329edc525dd X-Google-Attributes: gid111659,public From: Dr John Stockton <jrs@merlyn.demon.co.uk> Subject: Re: String to Integer Problem Date: 2000/03/23 Message-ID: <Dm3clHAsyf24Ewbj@merlyn.demon.co.uk> X-Deja-AN: 601418689 Content-Transfer-Encoding: 8bit X-NNTP-Posting-Host: merlyn.demon.co.uk:158.152.233.145 References: <953775438.4306.0.nnrp-09.9e98e529@news.demon.co.uk> Content-Type: text/plain;charset=iso-8859-1 X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 953839780 nnrp-02:13034 NO-IDENT merlyn.demon.co.uk:158.152.233.145 Organization: Home, 'Surrey', UK MIME-Version: 1.0 Newsgroups: comp.lang.pascal.borland,comp.lang.pascal.misc,borland.public.turbopascal