Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with functions

Posted on 1998-08-05
2
Medium Priority
?
192 Views
Last Modified: 2010-04-04
I must be missing something simple. I add the the following function to unit1.pas:

function CheckPath(s: String): String;
begin
if (AnsiLastChar(s) = '\') then
CheckPath := Copy(s,1,Length(s) - 1)
Else
CheckPath := s;
end;

when i try to do s := CheckPath(DirectoryListBox1.Directory) in a procedure I get:

[Error] Unit1.pas(49): Undeclared identifier: 'CheckPath'

What am I missing?
0
Comment
Question by:LostOne
[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
2 Comments
 
LVL 2

Accepted Solution

by:
kjteng earned 200 total points
ID: 1359919
Lets say the unit contain the checkpath function is called UnitZ.

There are few possiblities:
1. If you are calling the function from other unit (say unit1), you have to: [a] add the word unitZ in the uses clause of unit1 [b] declare the checkpath function in the Interface Section of unitZ.
2. If you just want to call the checkPath function within unitZ only, then you do not need to declare it in the interface section. However, the code for this function must come before you called it. ie

implementation

function CheckPath(s: String): String;
begin
  ...
end;

procedure Tform1.ABC;
var s: string;
begin
  .....
  s := CheckPath(DirectoryListBox1.Directory)
end;

.


BUT NOT

implementation

procedure Tform1.ABC;
var s: string;
begin
  .....
  s := CheckPath(DirectoryListBox1.Directory)
end;

function CheckPath(s: String): String;
begin
  ...
end;

.
0
 

Author Comment

by:LostOne
ID: 1359920
Thanks, the function came after the procedure I was trying to use it in. Doesn't make a difference is VB so I didn't even think aobut that.

Thanks.
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.

Question has a verified solution.

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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