Solved

Need help compiling a delphi program

Posted on 2004-09-16
6
1,148 Views
Last Modified: 2008-01-16
Hi ..
I need help compiling a delphi application.I do not know Delphi at all.
I am trying to compile this project but it gives me error on

A:=VarArrayCreate([0, 25], varVARIANT);


The error message is pas(174) Undeclared identified 'vararraycreate'

Am i missing any "Include file" or something that tells compiler what vararray create is.As afar as i know the syntax of this vararraycreate is correct.

Thanks.

FUNCTION GETWINDIR(SENDER: TOBJECT): STRING;
VAR
XX: STRING;
A: VARIANT;
ENVPSTR: PCHAR;
STOP: BOOLEAN;
NN:INTEGER;
NA: INTEGER;
N: INTEGER;
STR_WINDIR: STRING;
BEGIN
STR_WINDIR:='';
STOP:=FALSE;
GETMEM(ENVPSTR,512);
ENVPSTR:=GETENVIRONMENTSTRINGS();
A:=VarArrayCreate([0, 25], varVARIANT);
NN:=1;
NA:=0;
A[NA]:='' ;
REPEAT
     IF ENVPSTR[NN]<>#0 THEN
          BEGIN
          A[NA]:=A[NA]+ENVPSTR[NN];
          END
       ELSE
          BEGIN
          IF ENVPSTR[NN+1]=#0 THEN
               STOP:=TRUE
            ELSE
               BEGIN
               NA:=NA+1;
               A[NA]:='';
               END;
          END;
     NN:=NN+1;
UNTIL STOP ;
FREEENVIRONMENTSTRINGS(ENVPSTR);
FOR N:=1 TO NA DO
     BEGIN
     NN:=POS('=',A[N]);
     IF NN<>0 THEN
          BEGIN
          XX:=COPY(A[N],1,NN-1);
          IF XX='windir' THEN
               BEGIN
               STR_WINDIR:=COPY(A[N],NN+1,255);
               BREAK;
               END;
          END;
     END;
RESULT:=STR_WINDIR;
END;

FUNCTION TRIMCOMMASPACE(STR_IN: STRING): STRING;
{THIS FUNCTION IS INTENDED FOR USE WITH NUMBERS - ENTERED AS STRINGS -
WHICH MAY CONTAIN COMMAS OR SPACES AS THOUSANDS SEPARATORS.
THE FUNCTION RETURNS THE INPUT STRING, LESS COMMAS/SPACES}
VAR
INTCNT: INTEGER;
STR_OUT: STRING;
BEGIN
STR_OUT:='';
FOR INTCNT:=1 TO LENGTH(STR_IN) DO
     BEGIN
     IF (STR_IN[INTCNT]<>',') AND (STR_IN[INTCNT]<>' ') THEN
          STR_OUT:=STR_OUT+STR_IN[INTCNT];
     END;
RESULT:=STR_OUT;
END;
0
Comment
Question by:vikas1675
  • 4
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
Validor earned 250 total points
ID: 12077667
You are likely correct.  If the identifier is undeclared, then you're usually missing a unit in the USES clause.  In Delphi 5, it is declared in the SYSTEM unit, and is always available (the SYSTEM unit is always included in your project).  In Delphi 6 and 7, it is declared in the VARIANTS unit.  

It is strange that this code (which I assume you inherited) once compiled (again, assuming) but now won't.  The most likely cause of this is that the code was written in Delphi 5 and is now being compiled in Delphi 6 or 7.  That's okay.  This problem is not hard to fix.  If possible, try compiling the ORIGINAL source under Delphi 5 to see what happens (that is, source that you have not loaded and SAVED in Delphi 6+).

To fix the problem, add the word VARIANTS to the USES clause list.  There are two USES clauses in each Delphi unit.  The IMPLEMENTATION USES is the USES clause that appears immediately after the keyword IMPLEMENTATION.  If you put it here, it has minimum scope.  If it still causes any problems, you may add it to the USES clause that immediately follows the INTERFACE keyword (at the very top of the unit).  That has a wider scope.

3 examples (just to give you an idea):

uses variants;

uses
  Windows, Messages, Variants, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs;

uses
  Windows,
  SysUtils,
  Variants;

A UNIT, of course, is synonymous with a single source file, such as a .PAS file (mostly).
0
 

Author Comment

by:vikas1675
ID: 12078096
You are absolutely correct.The application was coded in ver 5 and now i am trying to compile it in ver 7

It was missing Classes too.So I added that and that part is compiling .
So thanks a ton for your help.

I have one more question.
The program has an interface to oracle.It is lookiung for ora.pas.
I serched for Odac on the net and found odac by crlab.I downloaded and installed it but didn't help.The program won't compile now as it can't find this ora.pas file.
Any clues??
0
 

Author Comment

by:vikas1675
ID: 12078306
I looked at older version of Delphi and ora.pas exists in program files\borland\odac\lib\ora.pas but on version 7 it is not there.
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.

 

Author Comment

by:vikas1675
ID: 12078611
Sorry..I was wrong.there is no ora.pas in ver 5.0 too.
0
 
LVL 3

Expert Comment

by:Validor
ID: 12078784
I have no ora*.pas on my system (which includes Delphi 3, 5, 6, 7, 8).  This tells me that in the Delphi 5 IDE, someone installed a third-party component which used this .pas file.  When you load the project into Delphi 7, did you get a popup telling you that a component was missing?  

Try a GREP search to find ora.pas in your Delphi 5 subdirectories.  It may reveal a .DPK file that contains the text.  

This may be harder to fix.  If this is the case, you'll have to install that component into Delphi 7, or rip it out and replace it with something else.  Not all Delphi 5 components will compile in Delphi 6 and 7.  Starting with Delphi 6, it forces components to follow a new rule.  Those that don't have to be converted to work in Delphi 6 and 7.  Not component designers complied.  If you have this problem, here is a URL that tells you how to fix it.

http://bdn.borland.com/article/0,1410,27717,0.html

Remember this link.  Everybody needs it at some point.  :)
0
 

Author Comment

by:vikas1675
ID: 12078973
When i opened the application in ver 7 then a bunch of errors showed up .I downloaded the ODAC from www.crlab.com/odac/  and the errors went away.
Actually this application was written by a programmer outside our company.It was a one man show.he passed away and now it came to me.So there is no way to know what he was using.I am an Oracle programmer and have absolutely no idea of Delphi.
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

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

20 Experts available now in Live!

Get 1:1 Help Now