forums

TNT Basic Forums > Programming Q&A
1. Is there a way to pass an entire array into a procedure?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-26-2006 11:37

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

1. Is there a way to pass an entire array into a procedure?

2. And also call a variable using string
eg.



int Variable1
string array(2,1)
int arraysizex(3),arraysizey(3)

array(0,0)="Variable1"


Procedure LoadInDefault(array1)'''(1) happening.
int i
for i=0 to arraysize-1
Variable array(i,0) =array(i,1) '''(2) happening.
next i
end proc

LoadInDefault(array)

11-04-2006 23:02

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Er... No and No.

If you want a proc to have access (R+W) to an array it needs to GLOBAL. This is currently the only way as you can't reference an address, which you would need in order to pass an entire array.

You can't store the name of a variable in a string and then reference the original variable through the content of that string in any language I've ever heard of (although it can be done through some scripting languages)... The contents of the string is a list of bytes and has no relationship to the address of an area of memory. When 'compiled' the actual human readable name is totally lost, so there is no link between the two.

Sorry...

Danny (nods)

11-05-2006 04:52

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

That's okay... I was just seeing if I could reduce my 150+ globals to a smaller number of them.

11-15-2006 22:58

Posted by:
Wil Hostman

Find more posts by Wil Hostman

You CAN take those globals and consolidate them into a single global array.

You can work with global arrays in procedures, you just can't pass locals.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.