Qbasicnews.com
July 15, 2018, 06:01: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]
  Print  
Author Topic: Keyword: Common  (Read 8999 times)
rdc
Senior Member
**
Posts: 176



WWW
« on: May 25, 2005, 11:09:25 AM »

The statement section in the Keyword list is done, except for the Common keyword, which is missing an example. I can't quite figure this one out, so if someone could work up a little example, that would be great.
Logged

keeling
Forum Regular
**
Posts: 149



WWW
« Reply #1 on: May 25, 2005, 04:57:30 PM »

A lot of FB's keywords are like QB. Use the QB Online Help at the top of this screen (look under index) to get an idea.

What I have gathered, (and please correct me if I am wrong), is that COMMON allowed global variables (consider bad practice). It could even be used between exe's.

Here is a quick example. Not exactly what I'd put in the documnets, but it should give you an idea about the command.

Code:
Option Explicit
Common shared A as double

sub TestIt
    A = 6
end sub

A = 5
? A
TestIt
? A
sleep
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #2 on: May 25, 2005, 05:03:22 PM »

I should update that quickhelp so it works in Mozilla browsers.  The only way to really do that is use unicode, which means I'd have to rewrite the scripts that generated the shtml.  Especially considering I lost them in a hard drive crash.

*sigh*
Logged
etko
Member
*
Posts: 45


WWW
« Reply #3 on: May 25, 2005, 08:22:50 PM »

Does FB support COMMON SHARED /Name/ construct fully? I hope, so it allowed some nice tricks.
Logged
Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #4 on: May 26, 2005, 01:20:31 AM »

doubt it supports the tricks Wink. Tricks are usually things that take long times to code :p.
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #5 on: May 26, 2005, 01:28:09 AM »

It isn't supported, as shown in the differences.. Common is much easier than in QB, as the variables order doesn't matter, only the names. What "trick"? Sharing data between different executables? That's called bad practice ;). (But yeah, variables can be shared between DLL's and client exe's using EXTERN)
Logged

etko
Member
*
Posts: 45


WWW
« Reply #6 on: May 26, 2005, 04:33:06 AM »

It was good to sharing data between modules. One module used all three global sets from library another only one. That module with shared only set was isolated from other "shares".

Code:
LIB CODE:

  COMMON SHARED /GlobalVars1/ Bla Bla
  COMMON SHARED /GlobalVars2/ Bla Bla
  COMMON SHARED /GlobalVars3/ Bla Bla

 MODULE 1:

  COMMON SHARED /GlobalVars2/
  COMMON SHARED /GlobalVars3/

 MODULE 2:

  COMMON SHARED /GlobalVars1/


This is bad practice? Maybe there should be section in wiki about bad practices written by experienced programmers...
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #7 on: May 26, 2005, 04:35:55 AM »

I dont' know.  Then you'd have a 60-page novel on spaghetti-coding.
Logged
etko
Member
*
Posts: 45


WWW
« Reply #8 on: May 27, 2005, 04:34:59 PM »

What does that spaghetti coding exactly means?

Even in Quake there are global vars used and their number is quite high Smiley.
Logged
Jofers
Been there, done that
*****
Posts: 1040



WWW
« Reply #9 on: May 27, 2005, 05:33:43 PM »

spaghetti-coding is code that's heavily obsfucated because it's been hacked over time and again.

e.g. a lot of gotos, few subs, few comments, unmeaningful variables large in number and thrown all over the place and alot of code that's been commented out for experimentation.  

Usually, a lot of personal projects are considered spaghetti-code.
Logged
helium
Member
*
Posts: 63


« Reply #10 on: May 28, 2005, 06:30:06 AM »

Quote
Even in Quake there are global vars used and their number is quite high

Quake was released 10 years ago. You can't compare that to todays coding practise.

Anyway it's Carmack and he is known to write code that nobody else wants to work with.
Logged
Anonymous
Guest
« Reply #11 on: May 28, 2005, 09:23:18 AM »

really, globals themselves are not bad practice, imo. its when you start "twisting" up the flow of the program (hence the term, spaghetti code) using them that they become a problem.
Logged
Radical Raccoon
I hold this place together
*****
Posts: 914



WWW
« Reply #12 on: December 07, 2005, 06:39:45 PM »

I used to use globals all the time! I think that's what caused me lots of problems. Sad
Logged

Pages: [1]
  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!