Qbasicnews.com
October 01, 2020, 06:41:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: DIM SHARED, COMMON SHARED  (Read 6787 times)
elspork
New Member

Posts: 19



« on: January 27, 2004, 04:05:30 PM »

What is the difference between

DIM SHARED a.variable
 
and

COMMON SHARED a.variable
Logged

astrator of Crocodiles
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #1 on: January 27, 2004, 04:45:18 PM »

DIM SHARED allows u to share a variable between subroutines while COMMON SHARED allows u to share a variable between modules(that obviously means you share the variable between subroutines).

Also, the rules for delcaring a COMMON SHARED variables are a bit different from DIM SHARED ones. For a bit detailed info have a look at qb's help.
Logged
stevie
Member
*
Posts: 43


« Reply #2 on: January 27, 2004, 05:09:12 PM »

DIM also allocates memory, while COMMON does not.
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #3 on: January 27, 2004, 05:10:54 PM »

Yeah, as i have said in my post, there are a lot of differences.

You should look up the help once in a while Wink Its pretty well documented.
Logged
pr0gger
I hold this place together
*****
Posts: 775


« Reply #4 on: January 27, 2004, 07:04:38 PM »

DIM:
http://qbasicnews.com/qboho/qckdim.shtml

COMMON:
http://qbasicnews.com/qboho/qckcommon.shtml
Logged

size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #5 on: January 27, 2004, 08:21:44 PM »

Though I'd reccomend against using COMMON at all, if you can help it. It has given me much trouble memory wise over Total Destruction, until they were removed.

Unless you're using multiple modules, I don't think there's a reason to use COMMON SHARED.
Logged

elspork
New Member

Posts: 19



« Reply #6 on: January 27, 2004, 09:12:55 PM »

yes, I've read the qb help. That's where I usually look first for this sort of thing. My problem is that I have been self-educated in my programming, so many of the finer details of coding and the way computers operate have eluded me. I find that the explanations in the qb help guide are better reminders than teachers. They tend to describe functions in a rather brief fashion.

I see that DIM SHARED and COMMON SHARED have the same effect, as far as I can tell, and I am wondering if there is some effective difference between the two, some reason to use one or the other.

Is it preferential that I allocate memory for universal variables? I've been using COMMON SHARED without trouble, but it sounds like others may have difficulties with my program if I do that.
Logged

astrator of Crocodiles
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #7 on: January 27, 2004, 09:42:23 PM »

Hey, we have something in common - I'm pretty much self-taught too, except for the odd tutorial or book.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Rokkuman
Na_th_an
*****
Posts: 1973



« Reply #8 on: January 27, 2004, 10:00:25 PM »

I look at people's source code
Logged
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #9 on: January 27, 2004, 10:34:11 PM »

i swindle like rockman
Logged

ammit potato!
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #10 on: January 28, 2004, 12:29:39 AM »

I'd use DIM SHARED where possible. COMMON SHARED (AFAIK) will use more memory if many modules are used than DIM SHARED. And COMMON SHARED arrays... I think you have to DIM the array then COMMON SHARED it, which is just silly Wink
Logged

Agamemnus
x/ \z
*****
Posts: 3491



« Reply #11 on: January 28, 2004, 01:04:25 AM »

I don't just use people's source code, I steal it and then change it so that no one knows I stole it.

 Cheesy
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
SCM
Wandering Guru
***
Posts: 311



« Reply #12 on: January 28, 2004, 01:14:28 AM »

It's true.  After Aga is done with it no one would recognise it.
Logged

hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
webberboy
Member
*
Posts: 95



WWW
« Reply #13 on: January 28, 2004, 01:35:05 AM »

Im self taught too, but I also use snitbits of others codes, sometimes modified, sometimes not...  For example, the challenge I won at http://forum.qbasicnews.com/viewtopic.php?t=4963 was won buy taking someone elses 3d code and adding some other elements to it to make it red/blue, ect.
Logged

url=http://webberboy.no-ip.com]Fine Hand-Crafted Pens[/url]
Pneumonoultramicroscopicsilicovolcanoconiosis:  Noun, A hypothetical, invented disease of the lungs, caused by inhaling mineral or metallic dust, such as silicon and quartzite, over a long period.]
elspork
New Member

Posts: 19



« Reply #14 on: January 28, 2004, 01:37:20 AM »

Great. Thanks.

I suppose it would be better still to avoid the universal variables whenever possible. I'm still working on that. I make liberal use of subroutines, and sometimes it gets complicated for simple me to selectively import variables that get used frequently.

confession: I have actually been using exclusively universal variables. I haven't had any memory problems yet (that I know of), but perhaps my programs would speed up like when I converted to DEFINT A-Z.

Well, actually I HAVE had memory problems. I've been assuming they were due to problems running QB in Microsquish.
Logged

astrator of Crocodiles
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!