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.

AppGameKit Classic Chat / [SOLVED] Option_Explicit & Global Constant

Author
Message
Nieb
10
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2016 19:02 Edited at: 12th Jul 2016 19:08
1: Option Explicit
This throws an "error: "number" has not been defined" while using a var on a GLOBAL array.



2: Global & Constant
Are #Constant vars inherently GLOBAL?
I noticed a different function was accessing a #Constant var outside of the function.

The author of this post has marked a post as an answer.

Go to answer

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Jul 2016 19:10 Edited at: 12th Jul 2016 19:11
Hi.

you must define number variable as global outside function.

Nieb
10
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2016 19:17 Edited at: 12th Jul 2016 19:31
I understand that if "number" is GLOBAL it works. However I'd like to keep it Local to the Function.
It doesn't seem to make sense that I can't use a Local var in a Function.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Jul 2016 20:37 Edited at: 12th Jul 2016 20:42
This post has been marked by the post author as the answer.
this old dim syntax will have a constant value and in past dim was allways global and inside a function allowed but in wrong scope.
if you have agkv2 maybe look this new array2 syntax here: https://www.appgamekit.com/documentation/guides/12_array_changes.htm
i believe you can resize with this .length = no
i don't know if it works without a constant.
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Nieb
10
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2016 21:09
Thanks Markus!
Just what I needed.

Login to post a reply

Server time is: 2024-11-25 05:14:29
Your offset time is: 2024-11-25 05:14:29