I was wondering if there was a way for a basic program to check if it has been executed before, hopefully with minimal changes to the system, and without crashing the program. Any Ideas?
I am pretty sure that there could be an assembly code created to do this. It would have to be assembly and not basic because of where the information would be stored. Perhaps Xeda could do it….
Also, why do you want to do this, it may help in development if you want to know how many times it has been used, if it was used, or what you want it for
well this is tough. im assuming you're making a game.
what you can do is attempt to recall a variable at the beginning of the program and match it's value to what the program assigned it
Using A as our variable and the number 5 as our checking value:
(beginning of code)
If A=5
Then
(your code for it has been used)
else
(first time running the program)
end
since these variables are constantly changing, it would be safer to use less used variables such as GDB and Matrices and such. But since calling a GDB or a Matrix (im not so sure about the matrix) that isnt defined would produce an error, use a list. the command SetUpEditor, when given an argument, recalls a list if it exists and unarchives, or if it doesnt exist, it will create it with a size of zero. so we use a custom list that we know will be used later in the game, such as ∟SAVE.
SetUpEditor SAVE
if Not(Dim(∟SAVE
then
(the program has not been used before)
else
(the program has been used before)
The Silver Phantom welcomes you
What he said. :p
I actually recall Orbix using this mechanic. If the list ORBIX is nonexistent, it displays the Angel Productions logo.
I did something similar in my Cookie Clicker game for the 84+. Using SetUpEditor. And, you know, an added benefit of SetUpEditor is that it unarchives the list if it is archived, as well. I always archive my lists for this reason, in case a RAM clear occurs.
:ClrHome:Disp "HOW DOES A","MATHEMATICIAN","LOSE WEIGHT?
:Pause "
:Pause "BINOMIALS!
:Pause "(BUY NO MEALS)":ClrHome
There is that benefit of SetUpEditor as Josiah said. I guess it really all depends on what you need it for. If it is a game, perhaps SetUpEditor is the best, if it is for something else, perhaps an asm code is better
Thanks. this is what I needed, but I also thought of something else:
Couldn't we set up a list using dim, then check if the values are 0?
4→dim(∟SAVE
if max(∟SAVE
Then
(code has been used)
Else
(hasn't been)
End
1→ ∟SAVE(1
As long as we knew SAVE will have non-zero values and what it's length will be.
Would this work? I guess SetUpEditor would be better anyway.
Put SetUpEditor before that. Because if the list is archived (as I recommend you do at the end of the program), the dim( command won't work.
:ClrHome:Disp "HOW DOES A","MATHEMATICIAN","LOSE WEIGHT?
:Pause "
:Pause "BINOMIALS!
:Pause "(BUY NO MEALS)":ClrHome