Board index » delphi » can someone help me with my delphi problems???

can someone help me with my delphi problems???

Hi there
I am trying to write a program in delphi (version 1) and I am coming across some
problems I cant seem to solve.

1) I would like to declare a constant of say 999999999999999, but the maximum I am
allowed to have is 9999999999.   Is there a way around this?  Will I have to declare it
as a variable and then allocate that larger number to it?

2) When it is compiling it tells me that the variables I am declaring are too big.
My declarations are (these constants are what I want to have):

const:
maxNodes = 200;        
  maxTechnologies = 100;        
  maxSuccessors = 50;  

type

  successorArrayType = array[1..maxSuccessors] of integer;      

  nodeRecord = record
    number: integer;    
    demand: integer;  
    numberOfSuccessors: integer;
    successorList: successorArrayType;  
   end;

  nodeType = array[1..maxNodes] of nodeRecord;

  technologyCapacityType = array[1..maxTechnologies] of integer;

  compatibleTechType = array[1..maxTechnologies, 1..maxTechnologies] of boolean;

  costRecord = record  
    fixed: real;
    variable: real;
   end;

  technologyCostType = array[1..maxTechnologies] of costRecord;

  HType = array[1..maxNodes, 1..maxTechnologies] of real;      

  GType = array[1..maxNodes, 1..maxNodes, 1..maxTechnologies] of integer;

When it is compiling it dies when it gets to GType.

If I change the constant declaration to something like:

const
maxNodes = 40
maxTechnologies = 20
maxSuccessors = 20

then it compilies OK, but this is way to small for what I want it to do.  Is there a
way around this reseriction? (I read in the help that it allows only 64K for local and
64K for global variables, surely there is a way around this).  A friend of mine said I
sould try using pointers , but I am not sure how to do that exactly, and when i tried
it it still died while compiling at the same place.  (i wrote p = ^GType, but the
compiler had died before it reached that line of code)

3) I want to use an OpenDialog component, (and SaveDialog) but I cannot simply insert
one onto a form and use that because my unit will be stand alone and called from
possibly many different forms, none of which I  can guarentee will contain an
OpenDialog or SaveDialog component.  What I tried to do was in one of my procedures
declare:

procedure xxx(*****)

var
openFileDialog:TOpenDialog;
.....

begin
.....
if openFileDialog.Execute then .....

unfortunatly when I ran this (it compiled OK) I got the following error message box:
 EGPFault.  
"General protection fault in moduel project .exe at 0007:4a74.  Process
stopped.

I looked this up and it said it is often due to objects not yet being created so I then
tried to insert the line:

TOpenDialog.Create(openFileDialog);
if openFileDialog.Execute then...

again it compiled OK, but when it got to the TOpenDialog.Create(openFileDialog) line I
got the same EGPFault error message box.
What am I doing wrong??
(I have included Dialogs in the uses declaration at the top of the unit)

4) Even if I remove all the big variable declarations, and if i pass in dialog boxes to
the open and save file routines (which I dont want to do but I just wanted to get my
code running) then the minute it hits the first begin in the very first routine the
program dies giving me the error "runtime error 202 at 0001:1099".  (AARRGGGHHH!)  I
cannot seem to find any reference to this error to explain what it means.  Can someone
help me?
(at the moment what I have is a form with a single button on it and an open and save
dialog component on it.  In my code there is an onbuttonclick routine which is meant to
start my code off, and it is at this begin that it dies).

all replies would be greatly appreciated

regards
andrew coyle

 

Re:can someone help me with my delphi problems???


Andrew, (or Sheryl? I'm not sure from the heading)

Quote
>1) I would like to declare a constant of say 999999999999999, but the maximum I am
>allowed to have is 9999999999.   Is there a way around this?  Will I have to declare it
>as a variable and then allocate that larger number to it?

Later versions of Delphi have overcome this. If you are under Win95,
you could try and go under Project/Options there should be a setting
for heap/stack size which you can increase. If you are running 16-bit
windows then I think your stuck. If you are change over, it's time.

Quote

>2) When it is compiling it tells me that the variables I am declaring are too big.
>My declarations are (these constants are what I want to have):

>const:
>maxNodes = 200;            
>  maxTechnologies = 100;    
>  maxSuccessors = 50;      

>type

>  successorArrayType = array[1..maxSuccessors] of integer;  

>  nodeRecord = record
>    number: integer;        
>    demand: integer;  
>    numberOfSuccessors: integer;
>    successorList: successorArrayType;      
>   end;

>  nodeType = array[1..maxNodes] of nodeRecord;

>  technologyCapacityType = array[1..maxTechnologies] of integer;

>  compatibleTechType = array[1..maxTechnologies, 1..maxTechnologies] of boolean;

>  costRecord = record      
>    fixed: real;
>    variable: real;
>   end;

>  technologyCostType = array[1..maxTechnologies] of costRecord;

>  HType = array[1..maxNodes, 1..maxTechnologies] of real;  

>  GType = array[1..maxNodes, 1..maxNodes, 1..maxTechnologies] of integer;

>When it is compiling it dies when it gets to GType.

>If I change the constant declaration to something like:

>const
>maxNodes = 40
>maxTechnologies = 20
>maxSuccessors = 20

>then it compilies OK, but this is way to small for what I want it to do.  Is there a
>way around this reseriction? (I read in the help that it allows only 64K for local and
>64K for global variables, surely there is a way around this).  A friend of mine said I
>sould try using pointers , but I am not sure how to do that exactly, and when i tried
>it it still died while compiling at the same place.  (i wrote p = ^GType, but the
>compiler had died before it reached that line of code)

Again this is related to the version of Windows & Delphi you are
running. You can use pointers, but not in the way you are using them.
You need to CREATE the integer arrays and then set a pointer to them,
not ALLOCATE the arrays like you are doing.

- Show quoted text -

Quote

>3) I want to use an OpenDialog component, (and SaveDialog) but I cannot simply insert
>one onto a form and use that because my unit will be stand alone and called from
>possibly many different forms, none of which I  can guarentee will contain an
>OpenDialog or SaveDialog component.  What I tried to do was in one of my procedures
>declare:

>procedure xxx(*****)

>var
>openFileDialog:TOpenDialog;
>.....

>begin
>.....
>if openFileDialog.Execute then .....

>unfortunatly when I ran this (it compiled OK) I got the following error message box:
> EGPFault.  
>"General protection fault in moduel project .exe at 0007:4a74.  Process
>stopped.

>I looked this up and it said it is often due to objects not yet being created so I then
>tried to insert the line:

>TOpenDialog.Create(openFileDialog);
>if openFileDialog.Execute then...

>again it compiled OK, but when it got to the TOpenDialog.Create(openFileDialog) line I
>got the same EGPFault error message box.
>What am I doing wrong??
>(I have included Dialogs in the uses declaration at the top of the unit)

Try this instead.

var
        MyOpenDlg : TOpenDialog;
begin
        MyOpenDlg := TOpenDiaolg.Create(Applciation);
        MyOpenDlg.Execute;
        MyOpenDialog.Free;
end;

Quote
>4) Even if I remove all the big variable declarations, and if i pass in dialog boxes to
>the open and save file routines (which I dont want to do but I just wanted to get my
>code running) then the minute it hits the first begin in the very first routine the
>program dies giving me the error "runtime error 202 at 0001:1099".  (AARRGGGHHH!)  I
>cannot seem to find any reference to this error to explain what it means.  Can someone
>help me?
>(at the moment what I have is a form with a single button on it and an open and save
>dialog component on it.  In my code there is an onbuttonclick routine which is meant to
>start my code off, and it is at this begin that it dies).

>all replies would be greatly appreciated

Not sure about that problem. Need more information, or try the other
fixes first & re-test.

                                                Good Luck,
                                                        Mike            

Re:can someone help me with my delphi problems???


Quote
Sheryl Coyle wrote:
> Hi there
> I am trying to write a program in delphi (version 1) and I am coming across some
> problems I cant seem to solve.

> 1) I would like to declare a constant of say 999999999999999, but the maximum I am
> allowed to have is 9999999999.   Is there a way around this?  Will I have to declare it
> as a variable and then allocate that larger number to it?

Integers are simply too small (in bits).Using a longint, you may have number from
-2147483648 to 2147483647.Alternatively, you may use a double (5.0 x 10-324 .. 1.7 x 10308
) or  extended
(3.4 x 10-4932 .. 1.1 x 104932 ) but expect a loss in accuracy.  Then again, you could
use a Currency for values from -922337203685477.5808 to 922337203685477.5807.

Quote
> 2) When it is compiling it tells me that the variables I am declaring are too big.
> My declarations are (these constants are what I want to have):

> const:
> maxNodes = 200;
>   maxTechnologies = 100;
>   maxSuccessors = 50;

> type

>   successorArrayType = array[1..maxSuccessors] of integer;

An integer is 2 bytes in size, so maxsuccessors * 2 = 100 bytes.

Quote
>   nodeRecord = record
>     number: integer;
>     demand: integer;
>     numberOfSuccessors: integer;
>     successorList: successorArrayType;
>    end;

Node record is  2 +
  2 +
  2 +
  100 = 106 bytes.

Quote
>   nodeType = array[1..maxNodes] of nodeRecord;

Maxnodes is 200 so Nodetype is 200 * 106 = <reaches for calculator> 21,200 bytes

Quote
>   technologyCapacityType = array[1..maxTechnologies] of integer;

MaxTechnologies is 100 so technologycapacitytype = 100 * 21,200 = 2,120,000 bytes

Quote
>   compatibleTechType = array[1..maxTechnologies, 1..maxTechnologies] of boolean;

Boolean uses a whole byte (how wasteful ;) socompatibletechtype = maxtechnologies *
maxtechnologies * 1 =  10,000

Quote
>   costRecord = record
>     fixed: real;
>     variable: real;
>    end;

Reals are 6 bytes, so CostRecord is 12 bytes.

Quote
>   technologyCostType = array[1..maxTechnologies] of costRecord;

100 * 12 = 1,200 bytes

Quote
>   HType = array[1..maxNodes, 1..maxTechnologies] of real;

Htype = 200 * 100 * 6 = 120,000 bytes

Quote
>   GType = array[1..maxNodes, 1..maxNodes, 1..maxTechnologies] of integer;

gtype = 200 * 200 * 100 * 2 = 8,000,000 bytes or 7.63 Megabytes!that's rather big.  If
you're using Delphi 1, then you'll have to juggle your stack, heap and data space into just
32K (or was it 64?)  7.63Mb + stack + heap > 32k.

Quote
> When it is compiling it dies when it gets to GType.

;)
<snip>

Quote

If you really need to acccess such huge amounts of data, consider making it available from
a database that can be spool from disk.

Quote
> 3) I want to use an OpenDialog component, (and SaveDialog) but I cannot simply insert
> one onto a form and use that because my unit will be stand alone and called from
> possibly many different forms, none of which I  can guarentee will contain an
> OpenDialog or SaveDialog component.  What I tried to do was in one of my procedures
> declare:

> procedure xxx(*****)

> var
> openFileDialog:TOpenDialog;
> .....

> begin
> .....
> if openFileDialog.Execute then .....

> unfortunatly when I ran this (it compiled OK) I got the following error message box:
>  EGPFault.
> "General protection fault in moduel project .exe at 0007:4a74.  Process
> stopped.

You need to create the TOpenDialog first, then free it when finished.

Var
 open1 : TOpenDialog;
Begin
   Open1 := TOpendialog.Create (Nil);
   If Open1.Execute then
...
   Open1.Free;
End;

Quote
> 4) Even if I remove all the big variable declarations, and if i pass in dialog boxes to
> the open and save file routines (which I dont want to do but I just wanted to get my
> code running) then the minute it hits the first begin in the very first routine the
> program dies giving me the error "runtime error 202 at 0001:1099".  (AARRGGGHHH!)  I
> cannot seem to find any reference to this error to explain what it means.  Can someone
> help me?

202?  Isn't that running out of stack space?  Try using 32 bit delphi ;)

<snip>

Quote
> regards
> andrew coyle

  Hope this helps,

Adrian.

Re:can someone help me with my delphi problems???


Dynamic allocation.

My 2 cents.
--

=========================================
bgrav...@vha.com
codi...@airmail.net
=========================================

Re:can someone help me with my delphi problems???


Quote
In article <34D9E325.9C2D0...@cherwell.com> Adrian Pickering <adr...@cherwell.com> writes:
>> Hi there
>> I am trying to write a program in delphi (version 1) and I am coming across some
>> problems I cant seem to solve.

>> 2) When it is compiling it tells me that the variables I am declaring are too big.
>> My declarations are (these constants are what I want to have):

>> const:
>> maxNodes = 200;
>>   maxTechnologies = 100;
>>   maxSuccessors = 50;

>> type

>>   successorArrayType = array[1..maxSuccessors] of integer;

The problem here, Adrian, is that you are asking for billions of bytes that
can't exist, or can't be stored.  Now, you can certainly create a class with
an array-style "read" and "write" method which would thereby allow you to,
indeed, *write* your code this way.  But the actual *implementation*, which is
where the computer actually takes those coordinates and comes up with an
integer, cannot possibly use a real flat-matrix.

You could encapsulate some kind of in-memory structure which uses a tree or a
hash-table or whatever, or if you really need to store this much data you
could use a file-based structure.  The code would view it as an "array" and
the code would be written that way but it would not, physically, be one.

Quote
>> 4) Even if I remove all the big variable declarations, and if i pass in dialog boxes to
>> the open and save file routines (which I dont want to do but I just wanted to get my
>> code running) then the minute it hits the first begin in the very first routine the
>> program dies giving me the error "runtime error 202 at 0001:1099".  (AARRGGGHHH!)  I
>> cannot seem to find any reference to this error to explain what it means.  Can someone
>> help me?
>202?  Isn't that running out of stack space?  Try using 32 bit delphi ;)

No, if memory serves me, it's hitting an abstract constructor or destructor.  
Basically where I saw it was when I said...

        var x: TStrings;

uh uh... it has to be a TStringList, because you can't successfully create or
destroy a TStrings...  I'm astonished that the language allows you to make
this declaration in the first place.  The only constructors and destructors
that "work" are in descendents of this class.  (See "abstract.")

Re:can someone help me with my delphi problems???


In article <34D92138.5...@iprolink.co.nz>, Sheryl Coyle

Quote
<swco...@iprolink.co.nz> writes:
>1) I would like to declare a constant of say 999999999999999, but the maximum
>I am
>allowed to have is 9999999999.   Is there a way around this?  Will I have to
>declare it
>as a variable and then allocate that larger number to it?

Delphi 1 help and Delphi 1 Object Pascal Language Guide says :-

"Type / Range / Significant Digits / Size in bytes

Comp / -263+1 .. 263-1 / 19-20 / 8

The Comp type holds only integral values within -263+1 to 263-1, which is
approximately -9.2 * 10**18 to 9.2 * 10**18"

But when one attempts to declare :-

MyHugeConst : Comp = 999999999999;

or

var MyHugeConst : Comp;

. . . only 999999999 is allowed.

What is going on ?

Alan Lloyd
alangll...@aol.com

Re:can someone help me with my delphi problems???


JRS:  In article <19980207093501.EAA26...@ladder03.news.aol.com> of Sat,
7 Feb 1998 09:35:57 in comp.lang.pascal.borland, AlanGLLoyd

Quote
<alangll...@aol.com> wrote:
>In article <34D92138.5...@iprolink.co.nz>, Sheryl Coyle
><swco...@iprolink.co.nz> writes:

>>1) I would like to declare a constant of say 999999999999999, but the maximum
>>I am
>>allowed to have is 9999999999.   Is there a way around this?  Will I have to
>>declare it
>>as a variable and then allocate that larger number to it?

>Delphi 1 help and Delphi 1 Object Pascal Language Guide says :-

Not relevant in a BP/TP ng.

Quote
>"Type / Range / Significant Digits / Size in bytes

>Comp / -263+1 .. 263-1 / 19-20 / 8

Typographically misleading.

Quote
>The Comp type holds only integral values within -263+1 to 263-1, which is
>approximately -9.2 * 10**18 to 9.2 * 10**18"

>But when one attempts to declare :-
>MyHugeConst : Comp = 999999999999;
>or
>var MyHugeConst : Comp;
>. . . only 999999999 is allowed.
>What is going on ?

Comp is not an "integer" type, but a "floating-point" one, albeit
restricted to integral values, by definition.  Therefore, while
        MyHugeConst : Comp = 999999999999; fails,
        MyHugeConst : Comp = 999999999999.0; is OK.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

Re:can someone help me with my delphi problems???


Quote
> Delphi 1 help and Delphi 1 Object Pascal Language Guide says :-

Please let me help you about comp.lang.pascal.borland

 comp.lang.pascal.ansi-iso Pascal according to ANSI and ISO standards.
 comp.lang.pascal.borland  Borland's Pascal incl. Turbo Pascal (not Delphi!)
 comp.lang.pascal.mac      Macintosh based Pascals.             ^^^^^^^^^^^
 comp.lang.pascal.misc     Pascal in general and ungrouped Pascals.

 comp.lang.pascal.delphi.advocacy Contentious issues related to Delphi.
 comp.lang.pascal.delphi.announce Delphi related announcements. (Moderated)
 comp.lang.pascal.delphi.components.misc General component issues.
 comp.lang.pascal.delphi.components.usage Using pre-written components.
 comp.lang.pascal.delphi.components.writing Writing Delphi components.
 comp.lang.pascal.delphi.databases Database aspects of Borland Delphi.
 comp.lang.pascal.delphi.misc General issues with Borland Delphi.
 comp.sources.delphi Delphi and ObjectPascal source code. (Moderated)

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/>  ; FIN-65101,  Finland

Spam foiling in effect.  My email filter autoresponder will return a
required email password to users not yet in the privileges database.

Other Threads