Author Topic: A new way to use subroutines : why not in an app ?  (Read 9645 times)

0 Members and 1 Guest are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
A new way to use subroutines : why not in an app ?
« on: October 09, 2012, 02:39:09 am »
Hi guys !

I was wondering with other members (including DrDnar and thepenguin77, it started here) how possible it was to define subroutines in an Axe program called into an app and call them from another classic Axe program.

So, I can say that it's possible since I did it :D



I used an Axiom I programmed on the fly called PageSwap ; it provides three functions to work with pages.

FunctionPrototypeEffect
getCurPage
Token : R>Pr(
getCurPageReturns in HL the current page
setCurPage(
Token : R>P?(
setCurPage(PAGEMake PAGE the current page
getAppPage(
Token : P>Rx(
getAppPage("APP"Returns the page of the app, or the current page if not found
appFunc(
Token : P>Ry(
appFunc(NUMReturns the adress of the NUMth func in the app. Then you can call it with (EXP)(ARGS) (make sure that you're not calling the Start func ! Also make sure that you're effectively in the app before calling funcs)

You'll find these func in the Angle menu [2nd] [apps].

Share comments :)

EDIT : added a fourth function to easily call subroutines inside an app.
« Last Edit: November 26, 2012, 08:21:37 am by Matrefeytontias »

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #1 on: October 09, 2012, 05:37:58 am »
This is nice work. Now you can write a shell in Axe.

Be forewarned: this will not play nice with Axe Fusion.

Also, there's the slight problem that it depends on Axe not changing the structure of its app initialization code. Fortunately, that's unlikely, and you can just keep using the old compiler for updates if such happens.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #2 on: October 09, 2012, 08:04:38 am »
I agree, excellent work.

Just watch out for commands that place themselves at the start of an app (though I'm not sure these exist).


The next step now is to make an app like this that runs a 24KB program that runs fullrene. 40KB of executable code!!! (As opposed to the library approach)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #3 on: October 09, 2012, 09:01:16 am »
Nice work here, very cool stuff. On another note, I've heard that Axe fusion is pretty broken at the moment, so it shouldn't be an issue *yet*.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: A new way to use subroutines : why not in an app ?
« Reply #4 on: October 09, 2012, 09:56:17 am »
Yeah, I thought so. But anyway I hadn't planned to use Axe Fusion with that, I already knew that it had trouble with everything out the current program (like vars).

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: A new way to use subroutines : why not in an app ?
« Reply #5 on: October 09, 2012, 01:04:00 pm »
Update !

I added a new command to the axiom in order to make the call of the app functions easier ; just check the screen, I updated it, as for the attachment :)
« Last Edit: October 09, 2012, 01:07:40 pm by Matrefeytontias »

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #6 on: October 09, 2012, 05:58:13 pm »
Well I didn't expect this at al... I have a question though.  Would it be possible for the API to be compiled along with the calling program?

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #7 on: October 09, 2012, 05:59:51 pm »
Well, due to my lack of knowledge, I can't understand what this axiom achieves D:
Sig wipe!

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #8 on: October 10, 2012, 12:53:38 am »
The idea is simple: You can now write an Axe app and an Axe program, and the program can call routines stored in the app. Since apps can be up to 16 K, and programs up to 24 K, you can now write combination Axe programs/apps with up to 40 K of combined code and data. (And if you need even more, there's still the files interface.)
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: A new way to use subroutines : why not in an app ?
« Reply #9 on: October 10, 2012, 01:15:36 am »
And you can also access several apps with a single program, which means a nearly unlimited amount of code =)

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: A new way to use subroutines : why not in an app ?
« Reply #10 on: October 10, 2012, 06:52:59 am »
I think you may have unconsciously made 2 page apps possible.

Offline Xaychru04

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
    • Xaychru04's blog
Re: A new way to use subroutines : why not in an app ?
« Reply #11 on: October 10, 2012, 08:50:06 am »
That could be very interesting !
And do you have to recompile the apps you need to compile the Axe program ?
If not, It can be faster to recompile programs that just changed a little...

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: A new way to use subroutines : why not in an app ?
« Reply #12 on: October 10, 2012, 10:33:08 am »
You only have to recompile the programs you changed :)

Offline Xaychru04

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
    • Xaychru04's blog
Re: A new way to use subroutines : why not in an app ?
« Reply #13 on: October 10, 2012, 12:29:50 pm »
So that could be very interesting :D

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: A new way to use subroutines : why not in an app ?
« Reply #14 on: October 31, 2012, 03:24:00 pm »
Wow seems very nice. This will definitively be handy for those with big RPGs and such files with complex engines. Is it fully useable yet or is it still very buggy?
« Last Edit: October 31, 2012, 03:25:37 pm by DJ_O »