Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 632
  • Last Modified:

Source code to Val procedure

Hi,

According to Delphi 7 help, the Val procedure is in the system unit. I can't find it there. I want to know if it always returns zero when Code is non zero.

My question is, where is the source code for Val?

Regards,

Bill
0
wipnav
Asked:
wipnav
  • 3
  • 2
1 Solution
 
Jase-CoderCommented:
You dont actually get the source code. The function/procedure prototypes are stored in the units like system. The function/procedure is a object file so you cannot view the source.

Well that is how C works, so, I guess that delphi will do the same.
0
 
Ivanov_GCommented:

   Project / Options / Compiler / Debuggins

   set there "Use Debug DCU" and when you execute your code Step Into the procedure ...
0
 
Ivanov_GCommented:

   Your system unit is in folder C:\Program Files\Borland\Delphi5\lib, unit system.dcu.

   Obviously the code you have in Source/RTL/Sys is not the unit compiled into this DCU. So use Step Into after you turn "Use Debug DCU". I think this should help ...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
The Val source code isn't available because it's built into the compiler

The System.pas header comment say:
             { Predefined constants, types, procedures, }
             { and functions (such as True, Integer, or }
             { Writeln) do not have actual declarations.}
             { Instead they are built into the compiler }
             { and are treated as if they were declared }
             { at the beginning of the System unit.     }
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
BTW: -->I want to know if it always returns zero when Code is non zero.

Not exactly. It depends on the type of the returned var.
See:
Delphi syntax:

procedure Val(S: String; var V; var Code: Integer);

if S is '1.2' and V is integer, code will be 1 and V the integer part of S that is 1 in this case....

So not every time that Code is non zero return 0 for V also...

Hope is clear...
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
--> if S is '1.2' and V is integer, code will be 1
should be
if S is '1.2' and V is integer, code will be 2
sorry for the typo
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now