Solved

Source code to Val procedure

Posted on 2004-04-15
6
615 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Dbf export problem to a Visual Foxpro application 6 234
how to center only a line in richedit? 4 69
Show Listview image from database (String field) 5 150
Delphi 2 77
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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