Solved

Source code to Val procedure

Posted on 2004-04-15
6
610 Views
Last Modified: 2010-05-18
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
Comment
Question by:wipnav
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 10833418
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
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10833592

   Project / Options / Compiler / Debuggins

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

Expert Comment

by:Ivanov_G
ID: 10833619

   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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10833735
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
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 50 total points
ID: 10833902
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
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10833918
--> 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using FastMM4... should I enable MMX option? 9 76
How to use Hashing sha1 in Delphi 2010 4 206
ddeman not working in activex 3 94
Making delphi communicate with a c# service 16 91
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now