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.

Author
Message
REDOXODER
21
Years of Service
User Offline
Joined: 11th Oct 2002
Location:
Posted: 11th Dec 2002 15:10
hello ,

i have some probs with function
i can modify data with the global def
but i can't use global for array.... :-{
so how to do ??
example:



the global sinu(360) does work why???

does patch 4 will "correct this" : modify data in function ...

thx

(sorry for my bad english)
Dreamora
21
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 11th Dec 2002 16:00
Array are always global! you aren't able to make "lokal" Arrays

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 11th Dec 2002 21:03
REDOXODER,
I tested the code. I am not sure what you are trying to achieve. Are you trying to print toto then titi?
Here the code that I modified to get that.



As for global and functions. I wouldn't mess around with Global stuff. It's used little in real programming applications. There's only a few instances where it is really needed. The code that you gave did run, but it printed Titi in an infinite loop. So you did achieve changing the value, but I am still not sure what you wanted to do there.
Here is my theory.
If you use globals, use gosubs
If you use functions do everything locally with returning values. That is how functions work. If we got referencing, you can pass the address of the variable that you want to change directly to the function and change it there without having to return the value. Of course that approach can get bad if you don't manage your memory correctly. Plus it is possible if you edit the wrong bit/byte you could crash your computer. That's why I use very little referencing in my C++ programs, but from time to time I am required to use it. I take care in my programming.
Plus a$ is a string not an array. Big difference. Remove the global a$ and the only thing that would print is toto. Otherwise by leaving in global a$ would make it global.
The code above proves my point.

Thanks.
SoulMan

I am my own and own my am I

Login to post a reply

Server time is: 2024-05-08 03:00:49
Your offset time is: 2024-05-08 03:00:49