|
Post by cyberchipz on Feb 16, 2020 18:30:47 GMT
I understand that line labels used for GOTO statements are a type of comment line.
Q: How is that LABEL treated? Do all comment lines become labels, and if so, how is that limited? I tested, and the answer is no, not all comments become labels.. to be a label the line must be a comment with only a single word.
I will try to answer my own questions in the future if I can do it.
I'm thinking that posting the question for current or future users might be a way to document my noobie questions. If you're good with that, I will continue to ask and answer when possible. This was the first time I went back and answered it.
Example: This is a comment * | Variable that counts Tasks
Does this also become a GOTO Label called Variable? If yes, does it just ignore everything after the first word, or does it have to be a single word? I answered my own question: No, labels are comments with only one word... but one can use an underscore, this is a label * | Variable_that_counts_tasks
Q: Is there a limit on the number of Labels in a macro? Partly answered, this came from my concern if every comment is also a Label; but since that's not so... I would still like to know if there's a limit?
Well, answered the first two... so had an idea...
Q: More of an idea than a question
Would it be possible, or can we already, add a comment after any line of code? I was thinking of this format, for example.
This would be a line of code with a comment after it... 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER4%::0 * | Initialize tracker count
I'm thinking this way we can associate directly the comment with the code. Perhaps a special coding to recognize the comment like |* instead of | * if needed and it would serve in place of the CR/LF to program flow. I think I've seen you use an ELSE statement to make a comment or perhaps I'm mistaken.
Thanks for any instruction you can provide me. I've learned so much over the last few days. I still keep reading the documentation but these questions popped up and I couldn't find anything that clarified an answer.
|
|
|
Post by cyberchipz on Feb 16, 2020 23:08:46 GMT
I'm just brainstorming here: so anyone can pipe in, I'd appreciate it.
On continual examination, if comments had their own line number, along with the line labels, things would be so much easier. (sigh) I was trying to develop a system for gosub and return, and that's the issue I'm running into. It's not lost on me that it would require a rewrite of previously existing macros, and that's the rub! So, I'm trying to come up with an algorithm that would count the comments and labels at any given line... because the issue with %RETURN% is that it gives the current REAL line number which includes comments and labels up to that point.
Perhaps simply adding a feature which would give one the choice of going to a real line number, or the older line number that's showing might work or at least be transitionally sound.
And there's the rub; I'm trying to find a way that wouldn't require any or much work from Steve. My head keeps telling me there's a way. Perhaps placing Subroutines at the beginning or end of the macro, or knowing the count of comments and labels at the start of the subroutine section. Perhaps being able to pass a line label would work. I'm just brainstorming here.
If we could pass a line label, then we could gosub to a line label, and return to a line label. That would allow us to use the subroutine anywhere. The label would have to be passed, because only the passing routine would know where it was going to come back.
Another thought was the concept of a stack, which is how it's done in machine language. You could PUSH label (a return location) onto the stack, and when the subroutine was done, it would POP label (the return location) off the stack to go back. This isn't the the first time I was thinking a stack could be useful. Since I don't know your full background on programming Steve, I'm not sure on what level to talk. It seems (and the exemplary nature of MMM suggests you're quite savvy). I mean, I know what it takes to create a macro builder that can access processes at the level it does.
So, it just dawned on me that reading and writing to a file could be made to act like a LIFO stack, Last In, First Out. And since we can store numeric values we can push them in and pop them out whenever. I am seeing I have much to learn about MMM! LOL.
OR, I could use a dedicated %STRING% for it, with fixed length... hmmm, does MMM have a left$ or right$ or mid$ command. Well, enough brainstorming for now. So, perhaps build a PUSH and POP macro first. I saw that MMM can load and run a macro from a file in runtime. OK, this helped. Perhaps I should just delete this post... but, let me try leaving it up, and if anyone has some pointers for me. :-) And, thanks if you do... OH just realized... line numbers keep changing, and there's the rub... Yeah... need to perhaps goto a line label that's named in a string. GOTO MACRO LINE %string%. Well maybe it already does it. I know GOTO MACRO LINE %integer% works... but line numbers change... Labels don't.
|
|
|
Post by cyberchipz on Feb 16, 2020 23:56:03 GMT
I'm just brainstorming here: so anyone can pipe in, I'd appreciate it. AND, just like that... solved. Maybe it's my age that I try to make things so complicated... or maybe I'm just not versed in MMM yet. (Yeah, I'll buy that!) So, simply I just needed a break from the bright lights, to calm down and think... it was as simple as this... and I now have subroutines. * | Head 1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::Head2 2 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::Get_Return 3 | RUN ACTION | GOTO MACRO LINE | %STRING1% * | Head2 4 | RUN ACTION | MESSAGE PROMPT | Stopped here from Sub::%STRING%::1 5 | RUN ACTION | STOP * | Get_Return 6 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::%STRING% 7 | RUN ACTION | MESSAGE PROMPT | Stopped here from Head::%STRING%::1 8 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::Made it back 9 | RUN ACTION | GOTO MACRO LINE | %STRING1% And best of all... I didn't have to ask Steve for a anything... (I'm trying Steve, honest I am! ;-) As my father would say.... "You sure are!" The worst part is I'm having more fun playing with this, than I did with my game! My "clan mates" are starting to notice.
|
|
|
Post by Steve on Feb 21, 2020 6:04:15 GMT
I understand that line labels used for GOTO statements are a type of comment line. Q: How is that LABEL treated? Do all comment lines become labels, and if so, how is that limited? I tested, and the answer is no, not all comments become labels.. to be a label the line must be a comment with only a single word.
I will try to answer my own questions in the future if I can do it.
I'm thinking that posting the question for current or future users might be a way to document my noobie questions. If you're good with that, I will continue to ask and answer when possible. This was the first time I went back and answered it. Example: This is a comment * | Variable that counts Tasks Does this also become a GOTO Label called Variable? If yes, does it just ignore everything after the first word, or does it have to be a single word? I answered my own question: No, labels are comments with only one word... but one can use an underscore, this is a label * | Variable_that_counts_tasksQ: Is there a limit on the number of Labels in a macro? Partly answered, this came from my concern if every comment is also a Label; but since that's not so... I would still like to know if there's a limit? Well, answered the first two... so had an idea... Q: More of an idea than a question Would it be possible, or can we already, add a comment after any line of code? I was thinking of this format, for example. This would be a line of code with a comment after it... 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER4%::0 * | Initialize tracker count I'm thinking this way we can associate directly the comment with the code. Perhaps a special coding to recognize the comment like |* instead of | * if needed and it would serve in place of the CR/LF to program flow. I think I've seen you use an ELSE statement to make a comment or perhaps I'm mistaken.
Thanks for any instruction you can provide me. I've learned so much over the last few days. I still keep reading the documentation but these questions popped up and I couldn't find anything that clarified an answer. Chip sorry i've been really busy lately with work and well...just life in general. Haven't had much free time for anything, especially MMM. On a side note - i do enjoy reading your posts. They do make me laugh a little, in a good way. You answered the first two yourself - nice. The third: Q - Can we have comments after the line (at the end of the line) A - Noooo this it will fail. BUT we can have this...You might not have discovered this yet. its probably going to spin you out. (right click - edit entry - loop line - add/remove or ctrl+L on a line(s))
5 | RUN ACTION | MESSAGE PROMPT | %TIME% %random_1-1000%::%random_500-1000%::1 | loop 2::100
Again i've run out of time for now. I haven't finished reading your other posts but will get round to them. Cheers Chip
|
|
|
Post by cyberchipz on Feb 21, 2020 9:02:31 GMT
5 | RUN ACTION | MESSAGE PROMPT | %TIME% %random_1-1000%::%random_500-1000%::1 | loop 2::100 Q: I'll take, what is epilepsy for 1000 Steve! A: What is a good thing I don't have... good thing you didn't type in 3::100! lol
That *could* make one loopy... Are you trying to say you're loopy! :-) Makes for a good thing for debugging when I keep missing the debug message cause I put in a ::1 instead of a ::0
I was starting to go a bit loopy playing with it... Looks a bit like an alarm clock going off... or a quick way to make a line into a place to pause... yeah.. I can see uses... :-) Thanks!
|
|