Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Tue Nov 21, 2017 3:56 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Arrays Questions?
PostPosted: Thu Dec 04, 2008 1:01 pm 
Offline

Joined: Tue Aug 08, 2006 7:46 am
Posts: 2
Good Afternoon,

Is there a command to deallocate an array once it has been populated with data? I want to make sure
it is "clean" before I use it again. I know I could set all the array elements to zero with a loop but I'm wondering if there is a better way.

In this application I am calculating points which are then sent to a Galil controller. If I pause with a breakpoint and hover over the array name with the mouse I see a tip which says "<Large array. Double-click to view>. However double-clicking does not seem to do anything. Is there a way to view a "large" array for debugging purposes.

I'm using a G55 and Foundry 2.5

Thanks,

Steve


Top
 Profile  
 
 Post subject: Re: Arrays Questions?
PostPosted: Thu Dec 04, 2008 1:53 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
To clear out an array, the easiest way is to call Redim(array, 0) which will make the array zero size. Be sure to redim the array back to the appropriate size before reusing it.

When you redim an array to a size larger than it was previously, all new elements are set to the default value for that data type. For numeric data types that is zero.

Code:
dim i as integer
dim x[] as integer

'Allocate space for x
redim(x, 50) 'All elements are set to zero

for i = 0 to 49
    x[i] = 100
next

'Shrink X
redim(x, 25) 'x now contains 24 elements.

'Grow X again
redim(x, 50)

'At this point, elements 0-24 contain the value 100 while
'elements 25-49 contain the value 0


To view the contents of a large array, type the array name in the Watch Window. Double click there to view the value.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: Re: Arrays Questions?
PostPosted: Thu Dec 04, 2008 3:14 pm 
Offline

Joined: Tue Aug 08, 2006 7:46 am
Posts: 2
Jeremy,

Perfect! Thanks!

Steve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group