Page 1 of 1

Dim & Define Dim ???

Posted: Tue May 09, 2023 12:48 pm
by Caronte3D
Which is the purpose of Define Dim over symple Dim?
No error but... is the same? :?

Re: Dim & Define Dim ???

Posted: Tue May 09, 2023 1:12 pm
by mk-soft
Can probably be left out :?: :!:

Code: Select all

EnableExplicit

Dim vars(10)

Procedure foo()
  Shared vars()
  Debug vars()
EndProcedure

Re: Dim & Define Dim ???

Posted: Tue May 09, 2023 3:05 pm
by Fred
It's the same.

Re: Dim & Define Dim ???

Posted: Tue May 09, 2023 6:14 pm
by Quin
Does this also apply to things like NewMap?
If inside a procedure with Explicit enabled, I don't have to do Protected/Define NewMap. But what's the default in this case?

Re: Dim & Define Dim ???

Posted: Wed May 10, 2023 5:44 am
by Demivec
Quin wrote: Tue May 09, 2023 6:14 pm Does this also apply to things like NewMap?
If inside a procedure with Explicit enabled, I don't have to do Protected/Define NewMap. But what's the default in this case?
NewMap creates maps as locals. This is the same as what Define does to make a variable local in scope. If you need something different you would have to specify it.

Re: Dim & Define Dim ???

Posted: Wed May 10, 2023 6:22 am
by idle
My understanding of define was to change the default variable type.

Define.f x,y,z

Re: Dim & Define Dim ???

Posted: Wed May 10, 2023 10:17 am
by mk-soft
Declare variables only for MainScope and can be used with shared in procedures.

This is how I understood it.

Re: Dim & Define Dim ???

Posted: Wed May 10, 2023 2:23 pm
by Quin
mk-soft wrote: Wed May 10, 2023 10:17 am Declare variables only for MainScope and can be used with shared in procedures.

This is how I understood it.
This was my understanding too. It's also helpful with Explicit enabled.