Virtual Humans Forum
Virtual Humans Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Virtual Humans
Partner website:
Chatbots.org
 All Forums
 Virtual Humans
 Programming
 Object Pascal, Free Pascal(FPC/FPK), Lazarus IDE
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 7

GrantNZ
Moderator



New Zealand
2677 Posts

Posted - Aug 28 2009 :  06:45:39  Show Profile  Reply with Quote
Sounds like you're on the right track.

In C++ you use the "new" command to create an array (or any other object) on the heap. "new" returns a pointer to the heap memory, which you then store in a pointer variable. This is as opposed to just creating the array/object, in which case it is stored in the stack, which has limited space.

In my experience (which doesn't really apply to Pascal ), a "static array" has a fixed-size (defined at compile-time), and lives on the stack. A "dynamic array" can have any size (defined at run-time), and is stored in the heap.

The "stack" is kind of limited-size scratch-memory, useful for small and/or short-term variables. (In C++ you can choose the size of the stack when you compile.) You typically use it for things like loop counters, and small variables carried throughout your program.

The "heap" is all other memory. In C++, anything on the heap is accessed through a pointer, and you have to explicitly create and destroy things on the heap (otherwise you end up with memory leak problems). You typically use the heap for all the mass data that your program is using, so that would be large objects, arrays, etc.

Hope this helps.... I have no idea how the paradigms transfer to Pascal (or especially the Pascal syntax!) but I suspect most of the concepts should be applicable.
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Aug 28 2009 :  08:54:35  Show Profile  Visit hologenicman's Homepage  Reply with Quote
I remember the "new" in C++ and having to explicitley destroy it when no longer needed.

I have been looking for such an item in Pascal, but I just haven't been smart enough to find it quite yet...

I'm really hoping that this is just going to be an alternate way of creating the object and that it will leave all the rest of my array templating and make-up alone.

Actually as it is now, I create the arrays, and then immediately create pointer for the arrays so that i can sort the arrays around as needed. If the Pascal equivalent of "new" works this way, then I should not have too much trouble with it...

I can destroy it easy enoug during the Finalization section of the AI script which runs at shutdown of the application.

I am trying to avoid Dynamic arrays due to my current array structure and throughput. I believe that I had tried some dynamic arrays at first but found that the HologenicMatrix has to bedefined for size from the very start so that the throughput can be dependably established. I may be wrong on this point, and I would really like the array to be dynamic so that it can be expanded at a later point without having to destroy the existing matrix of learned information in the process. I'll come back and revisit this issue at a later point during the pollishing stages of the application.

Thanks,
John L>
IA|AI

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 18 2009 :  04:19:07  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.

Edited by - hologenicman on Sep 18 2009 04:23:38
Go to Top of Page

GrantNZ
Moderator



New Zealand
2677 Posts

Posted - Sep 18 2009 :  05:56:12  Show Profile  Reply with Quote
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 18 2009 :  09:53:17  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.

Edited by - hologenicman on Sep 18 2009 09:59:21
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 18 2009 :  13:14:47  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page

GrantNZ
Moderator



New Zealand
2677 Posts

Posted - Sep 19 2009 :  10:02:06  Show Profile  Reply with Quote
You're not a true programmer until you've been interrupted by a sunrise Just kidding of course - get some sleep!!!

I'm glad you've got past that obstacle - programming sometimes seems like an endless racetrack full of hurdles - I'm looking forward to seeing your further developments
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 19 2009 :  23:22:02  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.

Edited by - hologenicman on Sep 19 2009 23:23:37
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 19 2009 :  23:33:52  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.

Edited by - hologenicman on Sep 19 2009 23:43:19
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 20 2009 :  18:37:53  Show Profile  Visit hologenicman's Homepage  Reply with Quote

Been doing some clean-up work.

I have moved some values from the "type" section into the "Const" section so that I can configure the compile from a single place more efficiently. This is similar to #define (I believe) as used in C.

Actually, const in Pascal/Delphi is the same as const in C/C++. What I was really looking for was a true equivalent to #define, but I haven't found it.

The const worked just fine for moving values up from the type(templates), but when I tried to use a const value in the "for" loops within the program I get a message that the identifier is already defined. It is acting like the for loop is trying to re-define the identifier. This confuses me since I can use a declared variable for the very same need in the function code without a problem...?

Oh, well, #define would probably work better if I could find it's use for pascal. I've been doing yahoo searches and coming up empty. Perhaps I should move over to Google for a while.

John L>
IA|AI

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 21 2009 :  10:01:48  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 21 2009 :  11:05:07  Show Profile  Visit hologenicman's Homepage  Reply with Quote

HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page

laackejim
Committed Member



USA
3274 Posts

Posted - Sep 21 2009 :  15:52:23  Show Profile  Reply with Quote

Uncle Jim (e=mc2)
Go to Top of Page

GamerThom
Dedicated Member



USA
2550 Posts

Posted - Sep 21 2009 :  16:51:22  Show Profile  Visit GamerThom's Homepage  Click to see GamerThom's MSN Messenger address  Reply with Quote

http://www.gamerthom.com/ IAlAI

Edited by - GamerThom on Sep 21 2009 17:08:47
Go to Top of Page

hologenicman
Moderator



USA
3318 Posts

Posted - Sep 21 2009 :  22:47:54  Show Profile  Visit hologenicman's Homepage
Thanks, Guys.

Sad to say, though, that the issue has to be in the functions themselves because I have the very same problem whether I am puting the declaration into the "define"(with C-macro) or into the "const". Both instances act as though the functions are re-declaring the identifier.

It's a bit of a head scratcher for me...

The value is only really used in a few "for" statements where I use it to establish the iterations. I have been suspicious of whether the For-statements are trying to re-create the identifier on a local scope...?

John L>
IA|AI




HologenicMan
John A. Latimer
http://www.UniversalHologenics.com

"If the Human brain were so simple that we could understand it,
we would be so simple that we couldn't..."
-Emerson M Pugh-

Current project:http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=816&whichpage=1

DISCOVERY: The more I learn, the more I learn how little I know.
GOAL: There's strength in simplicity.
NOTE: Goal not always achieved.
Go to Top of Page
Page: of 7 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Virtual Humans Forum © V.R.Consulting Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000