Author Topic: Celtic III app smart program run  (Read 4449 times)

0 Members and 1 Guest are viewing this topic.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Celtic III app smart program run
« on: August 24, 2009, 01:48:31 pm »
this is a small little piece of code I made that saves RAM/ROM wear by smartly running the prog
Code: [Select]
det(9                                     //loads the program list into Ans
if inString(Ans,"<progname>              //checks to see if program exists
then
if inString(det(0,"<progname>",7),"A       //checks to see if program is archived
then
"<progname>                            //saves the program name into Ans
real(10,0,1                            //creates temp file
If ("BB6D"=det(14,"XTEMP001",0,2)) or ("BB6C"=det(14,"XTEMP001",0,2
Then
Asm(prgmXTEMP001                    //runs temp file
Else
prgmXTEMP001
End
real(10,1,1                        //deletes temp file
Else
If ("BB6D"=det(14,"XTEMP001",0,2)) or ("BB6C"=det(14,"XTEMP001",0,2
Then
Asm(prgm<progname>              //if program is not archived, it will run it directly
Else
prgm<progname>
End
det(0,"<progname>",0              //and then archive it
End
[getkey]                            //just clears the last keypress and loads it into Ans
End
anything in [ ] is optional

EDIT: I have added Iambian's suggestion, with the Then command :P
hmm, I had also worked out a way to run a program that would run more without using the same temporary program, so you could have a huge tree of programs that would run each other without using the same temp program...of course it wasn't perfect, if you had another program run another, you wouldn't delete the last one you where on...I'll have to post the code when I remember it, so you guys can look at it
« Last Edit: August 25, 2009, 09:48:42 pm by Eeems »
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Celtic III app smart program run
« Reply #1 on: August 24, 2009, 04:26:12 pm »
so I guess this would be useful for those who want to make a BASIC shell or a BASIC game with external levels, right?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Celtic III app smart program run
« Reply #2 on: August 24, 2009, 06:25:44 pm »
yeah it would, but of course you have to hard code the program name into this, so yeah...
/e

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Celtic III app smart program run
« Reply #3 on: August 25, 2009, 01:38:17 pm »
I just made a smart program archive/unarchive which would only try to archive/unarchive the program if it isn't and if it exists
Code: [Select]
:If θ
:Then
:If inString(det(9),Ans
:Then
:If not(inString(det(0,Ans,7),"A
:Then
:det(0,Ans,0
:End
:"DONE
:Else
:"ERROR
:End
:Else
:If inString(det(9),Ans
:Then
:If not(inString(det(0,Ans,7),"R
:Then
:det(0,Ans,0
:End
:"DONE
:Else
:"ERROR
:End
:End
it will return "ERROR" if the program doesn't exist to the Ans variable, otherwise it will return "DONE"
it uses the theta variable to tell if it should archive or not, 1 means archive, 0 means don't
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Celtic III app smart program run
« Reply #4 on: August 25, 2009, 01:46:02 pm »
Sorry after your 2nd post I don't know what it's supposed to do anymore. Could you post an example of what it does in a screenshot?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Celtic III app smart program run
« Reply #5 on: August 25, 2009, 02:07:47 pm »
well this one will unarchive/archive programs only if they exist, and only if they are not archived/unarchived already. this one just makes it so the program doesn't have to be archived/unarchived at the start for it to work, it will put it into exactly what it wants you want it to be
the first one would run the program from the RAM only if it is on it, otherwise it will run it using a temporary program. this one saves ram wear and tear by a little bit

I'll post a screenshot tomorrow
/e

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Celtic III app smart program run
« Reply #6 on: August 25, 2009, 09:26:59 pm »
A little side note for the first one, you can automate the selection of whether or not it's a "BASIC" program or an ASM program by making the following test:
Code: [Select]
If ("BB6D"=det(14,"XTEMP001",0,2)) or ("BB6C"=det(14,"XTEMP001",0,2))
Then
//run code if ASM binary or hex
Else
//run code if "BASIC" program (no ASM header)
End
That bit employs the BINREAD command to check the leading token to determine if it's HexASM/ASM (respectively). If the first two bytes does not contain those tokens, it's probably safe to assume it's a BASIC program. The difference between the runs of code would be the addition of the "Asm(" token, but at least it can be further automated in this fashion.

EDIT: The reason why there's two tests (the or statement) is because it's a slightly different "token" depending on the exact form of the ASM program. Though the user might end up using either one or the other, the run of code I posted helps ensure that there will be no error if that little fact is neglected. Also, I put BASIC in quotes because I'm pretty sure someone (like me) would create a binary data file that lacks a header and would most likely be interpreted as a BASIC program insofar as much as the built-in editor is concerned. Again, I'm pretty sure that's not much of a concern, but I want to make it clear in case someone forgets about that type of possibility too. Unfortunately, I've no way to automate detection of that scenario.

EDIT2: Fixed code to include the forgotten "Then" statement. Gosh, I am SO out of touch with BASIC, it's not even funny.
« Last Edit: August 25, 2009, 10:29:02 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Celtic III app smart program run
« Reply #7 on: August 25, 2009, 09:41:44 pm »
ah, well thanks Iambian :)
hmm I was wondering if you could make a file type detection command for the next version of Celtic III, it would be really handy for this type of thing
hmm, now to write this down and use it :P

EDIT: btw, you missed the then statement :P
/e

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Celtic III app smart program run
« Reply #8 on: August 25, 2009, 10:38:26 pm »
"Filetype" as in "contents of header" ? If so, you'd want to look into det(9...), which is pretty much an ION-style file detector. In a space-delimited string, you can extract the file names that have that special header and run through the list one by one.

If by "filename", you'd want to look into det(32...)

Am I missing something?
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Celtic III app smart program run
« Reply #9 on: August 25, 2009, 10:44:51 pm »
I was just thinking of one that makes it easier....like having a command that will return something if the program in the argument is ion, or mirage, or dcs, or basic, or standard asm
/e