|
Forum Index : Microcontroller and PC projects : Questions about OPTION EXPLICIT
| Author | Message | ||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
I'm a little confused, as usual, by the manuals this time. I presume that: 1 - OPTION EXPLICIT has to be placed before any variables are defined. 2 - OPTION EXPLICIT may follow other OPTION commands. 3 - If OPTION EXPLICIT is used variables must be defined by DIM or LOCAL. Am I right so far? Now, when a variable is defined by LOCAL will that variable be visible to subs and functions called by the SUB or FUNCTION in which the variable is declared? In other words, are local variables inherited by child routines? Paul in NY |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
No, but it it would sensible to do so. Yes to both. It is easy to test this type of stuff - just fire up MMBasic and experiment. No. Geoff Graham - http://geoffg.net |
||||
| Azure Guru Joined: 09/11/2017 Location: AustraliaPosts: 446 |
Yes to 1, 2 and 3. Did a little testing to check the following answers below were correct. No to the last point a nested sub does not inherit the 'LOCAL' variables of any parent. To share variables in nested subs they must be passed as a calling argument or be global (declared in DIM's). To round things out the visibility of 'CONST' is the same, if declared in the main body it is visible to all and if declared inside a sub it is only visible within that sub. |
||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Thanks very much Geoff and John. I think I'm getting old. It's taken 80 years for me to think this. I have used many languages since I learned COBOL and FORTRAN back in the 1950s. Right now I am writing a thing that parses text in LUA and modifying a FoxPro (dBase - sort of) DBMS application,both for a charities, and my geothermal controller program in MMBasic and I find myself writing code in the wrong language. If you guys ever see me mixing Polish into my posts give me a shout telling me that it's time to hang up my keyboard. Paul in NY |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3466 |
Lua is certainly good for parsing, but for the sake of not having to learn a new language (one which does have its complexities), why not do it with MMBasic for DOS? PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Hi Lance. The LUA program is something that I put together about a year ago for a greyhound adoption group and I'm modifying it. MMBasic won't do the job. It reads 25KB long strings and changes text in them, and it's blindingly fast. The FoxPro database file contains 108,000 member activity records for all the Elks clubs in the Hudson Valley area and has been in use since I first wrote the program under dBase in 1992. I'm now doing a small update. Paul in NY |
||||
| LouisG Senior Member Joined: 19/03/2016 Location: AustraliaPosts: 129 |
You're not getting old Paul. You're not losin' it because you're usin' it. Nice to see you using Foxpro. I use it too though I'm not a professional programmer. I used to confuse writing IIF with IFF (an Air Force term). So hard to spot. I certainly could have used OPTION EXPLICIT back then. |
||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
Oh my Fortran DBase III and CPM was it was fun then too. Paul_L No way "keep the keyboard" and we'll just Google it. |
||||
| Bill7300 Senior Member Joined: 05/08/2014 Location: AustraliaPosts: 159 |
Unless you type your Polish in backwards,Paul. That should be OK. Reverse Polish Notation has long been an accepted practice in our vocation! Bill |
||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
While writing the far jump resolution code for an assembler at Cornell back in 1957 I inserted some remarks in Polish. IBM bought that assembler from Cornell about 1962. In 1991 I was poking around in the assembler source code for the 3090 assembler that Pan Am had and I found the Polish remarks I had inserted 34 years before. Apparently none of the army of IBM programmers who had worked on that source code down through the decades could read Polish so they didn't cut or modify my remarks. Reverse Polish Notation was first invented by Jan Lukasiewicz (pronounced Yan lu-KAshevich) in 1927. Apparently nobody understood it because it was later re-invented by Arthur Burks ... Don Warren ... Jesse Wright ... Fredrich Bauer ... and finally Edsger Dijkstra ... whew. It really isn't all that complicated. It eliminates the need for parentheses by forcing two operaands to precede each operator. It's used mostly in manipulating the stack. It's also called post fix notation instead of pre fix notation. a + b becomes a b + a + b - c becomes a b + c - (a + b) * c becomes a b + c * a + b * c becomes b c * a + (note the order of operations precedence) a + (b * c) becomes b c * a + a ( (b*c) + (d*e) ) becomes b c * d e * + a * It takes longer to learn, forces the human to write the first operation first, but it runs faster in a processor. Only Polacks can intuitively understand it. We really are different. Pavel Artur Jac Waclaw Lepkowski in NY |
||||
| Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Would like to get a little of feedback on declaring Functions. One example is:- Are these the only two valid ways of declaring the Function? The second example becomes very long... Is there a way to treat it like:- I've tried a few variations, but no success with anything bar the first two examples. Cheers Phil. |
||||
| Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Maybe this as well. Function BldReq$(Ad%,Fc%,A1%,A2%,N1%,N2%) BldReq=Chr$(Ad%)+Chr$(Fc%)+Chr$(A1%)+Chr$(A2%)+Chr$(N1%)+Chr$(N2%) BldReq=BldReq+CrcStr(BldReq) End Function Paul in NY |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |