|
Forum Index : Microcontroller and PC projects : QuickBasic has COMMON, is it a usual feature ?
| Author | Message | ||||
| zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 662 |
To my surprise (being a bit ignorant of BASICs) I see QuickBasic had a COMMON statement. Is that a usual feature of BASICs in general or is it a special addition ? |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3348 |
COMMON defines a series of variables that are shared with a new program run using the CHAIN command. I think that COMMON came from Fortran and it was also in GW BASIC which MMBasic imitated. But it never made it into MMBasic. This was mostly because the early versions of MMBasic (for the Maximite) shared all variables with the chained program. Peter's ports of MMBasic followed this practice so COMMON has not been needed. Geoff Edited 2025-12-20 12:22 by Geoffg Geoff Graham - http://geoffg.net |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 570 |
It's uncommon for BASIC. Fortran uses it but BASIC, not so much. |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 1788 |
I found a really cool use for it; My DOS app needed to run certain things without interruption. I reprogrammed the timer interrupt from 55mS to 1mS (compensated to preserve time/date) and hijacked the vector. This was mainly handling I/O in the background. I even had it in a QLB so that, even when I paused or single-stepped the QB code in the IDE, the ISR continued to run. COMMON: I used this to establish shared variables with the ISR routine. All QB needed to do was read/write the shared variables. Who says "DOS can't do real-time" QB was one heck of a product. |
||||
| zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 662 |
Thanks Quite a uh, non-trivial thing to add to an interpreter. I wonder if can I do it ? But it is calling me... maybe as a xmas indulgence to myself, to have a go anyway |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 570 |
GW-BASIC and MBASIC (and most other Microsoft interpreted BASICs) can run a program from another preserving all variables and keeping files open without having to declare the variables in a COMMON statement. |
||||
| cdeagle Senior Member Joined: 22/06/2014 Location: United StatesPosts: 268 |
Here's a COMMON block example from one of my FORTRAN programs. The source code of the COMMON block named 'e2m1.inc' is included in a typical subroutine with the FORTRAN include command. 'e2m1.inc' is a simple text file specifying the information to be shared. subroutine findsoi(ri, vi, rhelio, vhelio) c determine time and conditions at Earth SOI c ************************************ implicit double precision (a-h, o-z) external geo_eqm, rmobj include 'e2m1.inc' common /e2m1/ rtd, dtr, aunit, emu, xj2, tetol, rtol, & xmmu, smu, xmu(10), xmu_mars, req, rsoi(9), & xjdate0, xjdtip, xjdsoi, xjdca, & direct, revmax, dv1(3), dv2(3), & rito(3), vito(3), rfto(3), vfto(3), & tiwrk, tisaved, yi(6), & yfinal(6), ysaved(6), tradius, eq2000(3, 3), & rmca, xinct, rhsoi(3), vhsoi(3), & rfinal(3), vfinal(3), rmmme(3), vmmme(3), & ip1, ip2, isun, imoon, ij2, itype, isn |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8667 |
It's not MMFortran (or MMC or MMPascal or MMLisp or whatever) though. Thank goodness. :) Your mission, should you choose to accept it, is to find a way to do what you want in MMBasic. As always, should you or any of your IM Force be caught or killed, the Secretary will disavow any knowledge of your actions. This tape/disc will self-destruct in five/ten seconds. Good luck. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 662 |
Well I can see a way of adding named COMMON blocks to my interpreter, it already has the COMMON blank block useable. But tt may be better to just try to implement modules instead, which were from a later version (f95 ?) Needs more thought.. Well, maybe if Hollywood calls I could get onto the Mission Impossible set, then get Tom Cruise to ask his scientology contacts to send MMBasic to the Mother Ship...when it arrives of course ... I'd like to see that.. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |