Dim & Define Dim ???

Everything else that doesn't fall into one of the other PB categories.
User avatar
Caronte3D
Addict
Addict
Posts: 1362
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Dim & Define Dim ???

Post by Caronte3D »

Which is the purpose of Define Dim over symple Dim?
No error but... is the same? :?
User avatar
mk-soft
Always Here
Always Here
Posts: 6248
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Dim & Define Dim ???

Post by mk-soft »

Can probably be left out :?: :!:

Code: Select all

EnableExplicit

Dim vars(10)

Procedure foo()
  Shared vars()
  Debug vars()
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18234
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Dim & Define Dim ???

Post by Fred »

It's the same.
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Dim & Define Dim ???

Post 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?
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Dim & Define Dim ???

Post 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.
Last edited by Demivec on Wed May 10, 2023 8:31 am, edited 1 time in total.
User avatar
idle
Always Here
Always Here
Posts: 5903
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Dim & Define Dim ???

Post by idle »

My understanding of define was to change the default variable type.

Define.f x,y,z
User avatar
mk-soft
Always Here
Always Here
Posts: 6248
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Dim & Define Dim ???

Post by mk-soft »

Declare variables only for MainScope and can be used with shared in procedures.

This is how I understood it.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Dim & Define Dim ???

Post 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.
Post Reply