Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Proper Use of Dim/unDim Statements

Author
Message
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 26th Jun 2004 02:31
I recall vaguely reading a discussion on the matter, but I think I needed clarification in any case.

In DB Pro specifically.

Using DIM to create arrays, I also like to flush out the contents of the arrays at times. Is it proper to simply use the DIM statement again to clear the contents?

Also, when UNDIMing an array, does it create problems/crashes if you attempt to unDIM an array that is not already DIMed?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Jun 2004 03:12
You should use the UNDIM command to clear an array before using DIM to rebuild it.

It is safe to UNDIM an array that has not yet been DIMed.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 26th Jun 2004 03:22
Thankye.
Hop a long
20
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 26th Jun 2004 19:09
Could we continue this thread a little longer? I have two questions:
(1) In C you should unallocate memory resources before your program exits. Does that mean you should also UNDIM all arrays before your DBC program ends?
(2) Do you have to be careful not to overwrite arrays in DBC? If you assign more values than there is allocated memory will other data be overwritten?
Jerbo
20
Years of Service
User Offline
Joined: 16th Jun 2004
Location:
Posted: 27th Jun 2004 14:22
Just to add one more question to the mix.... Regarding the DIM command, Is there any other way to make a variable global in DBPro, other than using the dim command? i.e.:

dim variable(1)

I just feel weird creating one element arrays...
STE
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location:
Posted: 27th Jun 2004 20:40
You need to use the "global" command.
It is best to stick them near the start of your program.

e.g.
Global variable_name as integer

The help text in DBPro is decent regarding variables. Highlight the word "global" in DBPro and press "F1" on the keyboard to see it.

STE ;¬!

Login to post a reply

Server time is: 2024-09-22 14:18:24
Your offset time is: 2024-09-22 14:18:24