visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Delphi :: Undeclared Identifier (IsNan and LeftStr)


By: pipinana2002 U.S.A.  Date: 19/06/2003 00:00:00  English  Points: 20 Status: Answered
Quality : Excellent
Hi all..

I'm currently using Delphi 7.

I would like to validate whether the data inputted in Edit is numeric. Hence, I tried to use IsNan function. But everytime I want to run the program, I always encounter an error: Undeclared Identifier: IsNan

I also encounter the same problem when I want to take a few character of a string using LeftStr function. Anybody know how can I use these 2 functions? Do I have to declare it first or something.. coz I thought that it is declared by Dephi already..

Thanksss.. :)
By: ginsonic Date: 19/06/2003 13:34:00 English  Type : Comment
LeftStr is declared into StrUtils unit. IsNan is declared into Math unit.

Add to uses StrUtils,Math,....
By: pipinana2002 Date: 19/06/2003 13:53:00 English  Type : Comment
Hi ginsonic..

Can you give me an example of how to declare StrUtils and Math unit so I can use LeftStr and IsNan function? Thankss.. :)
By: VGR Date: 20/06/2003 05:50:00 English  Type : Answer
in your program, you've :
-a DPR file (the main source) with units referenced by a "Uses" clause
-PAS units referencing each other by "Uses" clauses, either in implementation or in interface sections

Choose the unit or source file where IsNan and LeftStr are used ;

in implementation (probably), amend or add the "Uses" clause following the line "implementation" so that it includes :

Uses SysUtils, Math;
By: pipinana2002 Date: 20/06/2003 18:25:00 English  Type : Comment
Hi..

I have tried the solution from VGR, but now I got this error when I want to run:
If IsNan(Edit1.Text) Then
......

There is no overloaded version of 'IsNan' that can be called with this arguments

Can you suggest what's the problem with this line? Thanks so muchh..
By: VGR Date: 20/06/2003 18:36:00 English  Type : Comment
of course.
IsNan (is Not A Number, x87 stuff here) is supposed to receive A NUMBER, not a string as Edit1.Text...

Just do :

If IsNan(StrToInt(Edit1.Text)) Then



or use Val(), as usual



By: andrewjb Date: 20/06/2003 21:27:00 English  Type : Comment
That's not going to work... the StrToInt will raise an exception.

You don't want IsNan.

Just do:

try
SrtToInt( Edit1.Text )
except
; /// It wasn't' a number - do whatever you want here
end;


And note that you'll get an exception when running in the IDE anyway - just hit F9 and it'll be trapped correctly.

By: ginsonic Date: 20/06/2003 22:19:00 English  Type : Comment
uses ................., Math, StrUtils............

VGR, LeftStr is declared into StrUtils and not into SysUtils.
By: VGR Date: 20/06/2003 22:23:00 English  Type : Comment
sorry 8-)

do I have to flagellate myself after each typo found ? :D
By: ginsonic Date: 20/06/2003 22:24:00 English  Type : Comment
function IsInt(const S: string): Boolean;
var
I, Err: Integer;
begin
Val(S, I, Err);
Result := (Err = 0);
end;
By: ginsonic Date: 20/06/2003 22:26:00 English  Type : Comment
?!?!?! :P

Nice speed in reply :)

By: pipinana2002 Date: 20/06/2003 22:59:00 English  Type : Comment
Hi again all..

Thanks so much for your helppp :):):) really2 very helpful for a beginner like me :D

I finally resolved this problem.. using the solutions from VGR and andrewjb.. thanks sooo muchhh.. :)

Do register to be able to answer

EContact
browser fav
page generated in 325.526950 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page