Solved

Need help compiling a delphi program

Posted on 2004-09-16
6
1,145 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 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

22 Experts available now in Live!

Get 1:1 Help Now