Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: josh landers on March 31, 2014, 07:21:01 pm

Title: How does one make an Axe Library, in Axe.
Post by: josh landers on March 31, 2014, 07:21:01 pm
Could someone please explain how to make a library in axe? Because I dont know ASM and have seen examples of a library in axe anyway.  I saw it use
Code: [Select]
:..titleand haven't been able to use this header, it seems axe didnt even recognize the use of a double period.  If someone can explain how axe libraries work and how they are made that would be great!
Title: Re: How does one make an Axe Library, in Axe.
Post by: Runer112 on March 31, 2014, 07:33:52 pm
The fact that an Axe source file starting with two periods (a subprogram/library) doesn't show up in the compile menu is intentional. That way, you don't have subprograms and libraries cluttering up the compile menu, since it doesn't make sense to compile either as a standalone executable.


Just include prgmLIBNAME as a line in your main program and the library will be included and compiled with your main program.
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on March 31, 2014, 07:39:24 pm
So then are the contents of the library just a collection of subprograms? Or can they be other things?
Title: Re: How does one make an Axe Library, in Axe.
Post by: Runer112 on March 31, 2014, 08:02:13 pm
Other than showing up in the compile menu or not, there's no inherent difference between an Axe source file that starts with one or two periods. There's nothing stopping you from using a source program that starts with one period as a subprogram or library, and if the compile menu didn't explicitly hide source files that start with two periods, you could compile those as main programs.

One important thing to keep in mind about this lack of differentiation is possible unexpected behavior in a case like the following:

Code: (prgmTESTSRC) [Select]
:.TEST
:SayHello()
:
:prgmSUB
Code: (prgmSUB) [Select]
:..
:Lbl SayHello
:Disp "Hello world!"
:Return

The execution path will, after the initial SayHello() is reached, mosey right on into prgmSUB and repeat it, due to there being no Return or other control block to stop it. So if you don't want execution to run into your subprogram/library, it's a good idea to make sure that you either include it in a place where you know execution won't naturally reach, or to make sure that your subprogram/library wraps its code in a block that will skip its execution, like If 0 ... End or Goto SubEnd ... Lbl SubEnd.

Also, a slight note: there are two quirks about inclusion of subprograms/libraries that come to mind. The first quirk is that you cannot include a subprogram/library from another subprogram/library (yet?). And the second quirk is that any changes a subprogram/library makes to the optimization target (size versus speed) will be reverted to the main program's settings when the subprogram/library is done being compiled.
Title: Re: How does one make an Axe Library, in Axe.
Post by: aeTIos on April 01, 2014, 05:22:45 pm
I lost you at the last 2 lines. But whatever  :p
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 02, 2014, 05:59:26 pm
Oh... ok well im off to work on my first lib! Wish me luck!
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 09, 2014, 04:10:43 pm
Bump
Well its not going so well, Im not able to use a string in a routine, and for some reason it doesn't return to the parent program. It just quits. I was looking to use addresses as well like you [runner112] did in greylib, but was completely unsuccessful.
I will post some code of whats not working later but what causes this to happen runner112?
Title: Re: How does one make an Axe Library, in Axe.
Post by: Matrefeytontias on April 09, 2014, 04:37:44 pm
Possible reasons of why it would quit instead of return to main execution :
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 10, 2014, 12:28:46 am
Possible reasons of why it would quit instead of return to main execution :
  • You use Returnr instead of Return at the end of the subroutine.
  • You do Goto Subroutine instead of Subroutine().
x
Neither nor
I cant see why this doent work... could it have to with the fact I didnt just use r1-r6?
Title: Re: How does one make an Axe Library, in Axe.
Post by: Matrefeytontias on April 10, 2014, 12:41:08 am
You can use whatever  variable or function within a subroutine. It'll be easier if you just post your code.
Title: Re: How does one make an Axe Library, in Axe.
Post by: Hayleia on April 10, 2014, 04:29:17 pm
Or maybe you used neither "Goto LBL" nor "sub(LBL)" nor "LBL()" but you thought that saying "prgmPRGM" would execute PRGM and if we hit a Return "inside the program" PRGM, we go back to the "main program". But that's not the way it works. There is only one program after compilation, and saying "prgmPRGM" in your code doesn't create any level (no main program and no subprogram), it just virtually copies-pastes the contents of PRGM in your "main program" where you put "prgmPRGM".
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 14, 2014, 12:50:31 pm
:.header
:prgmLIB
:ACT()
:other code

:.LIBSRC
:Lbl ACT
:r1->strg111
:Return

This doesnt work!!!
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 14, 2014, 01:16:18 pm
prgmLIB should be at the bottom of your source. Don't put a return in the end of it, but in the beginning. Also it should start with "..", not ".", although that's not the problem.


Like so :
Code: [Select]
:.header
:ACT()
:other code
:prgmLIB


:..
:Return
:Lbl ACT
:r1->strg111
Title: Re: How does one make an Axe Library, in Axe.
Post by: Hayleia on April 14, 2014, 02:11:46 pm
Well I was kinda right about the cause of the problem. And that's what Runer said when he wrote "make sure that you either include it in a place where you know execution won't naturally reach, or to make sure that your subprogram/library wraps its code in a block that will skip its execution, like If 0 ... End or Goto SubEnd ... Lbl SubEnd."

prgmLIB should be at the bottom of your source. Don't put a return in the end of it, but in the beginning. Also it should start with "..", not ".", although that's not the problem.


Like so :
Code: [Select]
:.header
:ACT()
:other code
:prgmLIB


:..
:Return
:Lbl ACT
:r1->strg111
I'd advise more to put the Return in the main program for more visibility. I just like to know where my program ends.

I am against using subprograms anyway, except for huge projects. You said it yourself in the zStart topic, you're wasting time swapping between your files, time that you could save if everything was at the same place. And you would not have problems being lost thanks to zStart's label menu. But whatever fits you I guess.
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 14, 2014, 07:41:17 pm
I'm not wasting any time currently but Illusiat is getting large and I'd rather split the source before it gets too complicated. The battle engine, map engine and game  specific code should be split anyway since it will be a modular engine.
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 15, 2014, 12:55:06 pm
prgmLIB should be at the bottom of your source. Don't put a return in the end of it, but in the beginning. Also it should start with "..", not ".", although that's not the problem.
Ok but what if I wanted to relese it?
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 15, 2014, 12:56:33 pm
If you want to release it you just give people the 8xp of your library and they can use it in the same way. ;)
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 15, 2014, 09:21:23 pm
Yah 100th post!
I also got some of it to work. Hoping to show and tell tommorrow!
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 16, 2014, 05:55:56 am
Nice to hear. Good luck for finishing it. :)
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 16, 2014, 12:43:00 pm
I am on the finishing touches!
When saving to an appvar, and storing a string. how does one pull the string back out to display it?
Title: Re: How does one make an Axe Library, in Axe.
Post by: TheMachine02 on April 16, 2014, 12:58:03 pm
If you have stored your string at the begining of the appv (with a copy for example), then you can use the pointer to the appv as a pointer to the string. Just remember that you have to store the 0 of the end of the string.
You can do for example, if the string "TOTO" + the 0 is stored in the appv TEST :
 
Code: [Select]
Getcalc("appvTEST")->P
Disp P

and it will display the string stored.
 
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 16, 2014, 01:03:22 pm
"TOTO"
This made me lol. :P
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 16, 2014, 04:09:55 pm
UPDATE :D


YAY!
Quote from: SourceCoder 3 (LIBRARY)
:.FILELIB
:...
:DO NOT COMPILE AND RUN!
:BAD THINGS WILL HAPPEN
:...
:Return
:.FSM("appvStr4",SIZE)
:Lbl FSM
:!If GetCalc([r1])->Θ
:GetCalc([r1],[r2])->theta
:End
:[r1]->{Θ}^^r
:[r2]->+length([r1])+1}^^r
:Return
:.FLL(filenum,"name","size")
:Lbl FLL
:If [r1]=1
:[r2]->+30}
:[r3]->+46}
:End
:If [r1]=2
:[r2]->+61}
:[r3]->+77}
:End
:If [r1]=3
:[r2]->+92}
:[r3]->+108}
:End
:If [r1]=4
:[r2]->+123}
:[r3]->+139}
:End
:If [r1]=5
:[r2]->+154}
:[r3]->+169}
:End
:If [r1]=6
:[r2]->+185}
:[r3]->+200}
:End
:Return
:.FKL()
:Lbl FKL
:DelVar Θ
:Return
:
:Lbl FBN
:!If GetCalc([r1])->[r2]
:GetCalc([r1],768)->[r2]
:End:SortD(Θ,768)
:Copy(Θ,[r2],768)^^r
:Return
:.FCL(byteSTRT,length(bytes))
:Lbl FCL
:For([r4],0,[r2])
:[r3]->+([r1]+[r4])}
:End
:Return
:
:Lbl FAR
:Archive Θ
:Return
If anyone can help me dubug this that would be nice...Please excuse the strange syntax.
Title: Re: How does one make an Axe Library, in Axe.
Post by: Runer112 on April 16, 2014, 06:08:11 pm
Ok so if anyone can help make sense of this that would be great!


... Didn't you write it? I don't understand why you're asking others to help you make sense of code that you authored. Unless you mean for others to help you debug it, in which case I see multiple things that are potentially errors, but I'm not really sure without knowing what any of this is supposed to do.
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 16, 2014, 06:25:42 pm
Well as I said since it's not meant to be compiled alone, it should start with two dots.
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 16, 2014, 08:20:30 pm
Ok so if anyone can help make sense of this that would be great!


... Didn't you write it? I don't understand why you're asking others to help you make sense of code that you authored. Unless you mean for others to help you debug it, in which case I see multiple things that are potentially errors, but I'm not really sure without knowing what any of this is supposed to do.
Partially debug, and also explain the appvar usages in it.
Yes I did author this code. But I used very limited knowledge.
Here is the original idea.
    A library that can help the programmer create a screen of information. The information is stored in an appvar. You can use this like a directory command, or as a game scores list. The end use is arbitrary.  There are three main commands.
FSM ( "appvDIRN", size )
will make a directory.
FLL ( #, name, size)
# is from 1- 6, the lib uses this to place up to six files.
Name should be a string
Size, an arbitrary value. It could be a level or score etc.
FPR ()
UNDER CONSTRUCTION
The other commands are
FBN (String OS VAR)
will make an output file of the appvar and I use pic, but you can also use prgm
FKL ()
Suppose to delete it,  doesnt work
FCL (START, LENGTH, constant)
Will fill a portion of the appvar with constant.
FAR ()
Archive the appvar



Hope this helps!
Title: Re: How does one make an Axe Library, in Axe.
Post by: alberthrocks on April 16, 2014, 10:24:39 pm
Ok so if anyone can help make sense of this that would be great!
Woah, you wrote this code and don't know what it does? And you want us to figure it out? Yikes!

It's great to have people collaborating on code, but we really can't write or debug code for you. Maybe snippets of code (3-6 lines), sure. But we can't do your whole project! (In fact, if your "snippets of code" compounds to your entire project, that's bad too!) You have to understand that everyone is busy - we'd love to help with programming questions, but you can't just dump code here and expect us to critique it.  ;) Before asking any questions, we want to see that you've done a bare minimum research into the questions you'd like to ask, and the APIs you're asking about. If you have looked everywhere - Google, Omnimaga forums, Axe documentation, etc. - then we are more receptive to helping you out! :D

So my challenge to you: what's wrong with your code? How can it be made better? What don't you understand about it, and how can you fix that? Spend at least 5 hours pondering on that, without any distractions, interruptions, or delays. If within that time, you've consulted every resource available, and you've put forth your best, good faith effort into solving this, and are sweating/head-desking over the issues with your code after 5 hours of heavy research and problem solving, come back to us for questions! If you still have questions then, I promise you that the stuff you'll be asking us will be great! ;)
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 17, 2014, 12:55:19 pm
Ok so if anyone can help make sense of this that would be great!
Woah, you wrote this code and don't know what it does? And you want us to figure it out? Yikes!
...
Before asking any questions, we want to see that you've done a bare minimum research into the questions you'd like to ask, and the APIs you're asking about....

Spend at least 5 hours pondering on that, without any distractions, interruptions, or delays. If within that time, you've consulted every resource available, and you've put forth your best, good faith effort into solving this, and are sweating/head-desking over the issues with your code after 5 hours of heavy research and problem solving, come back to us for questions! ...


Your putting words in my mouth, I wrote the code, I have now worked on this for 18 and I dont think its too much to ask for people to look at a post, see a major flaw (or even a minor one) comment on it and explain.


No I will not spend five hours of my day questioning what I wrote. Look at the post above yours and you will see that i cleared up the confusion about what it does.
  But I used very limited knowledge.
This is my point, I used to scrapes of information I was given and came up with something that works but I don't know how the appvar works, and still do not. I need some more information about why i cant pull the information back out. Was it put in wrong etc.?
Title: Re: How does one make an Axe Library, in Axe.
Post by: alberthrocks on April 17, 2014, 01:33:47 pm
Your putting words in my mouth, I wrote the code, I have now worked on this for 18 and I dont think its too much to ask for people to look at a post, see a major flaw (or even a minor one) comment on it and explain.
"if anyone can help make sense of this" is basically asking us to figure out what you wrote. That's kinda like blindly writing a letter in Arabic and asking someone to decipher it...
From my experience with coding (and pretty much everyone else's), the person who wrote the code knows it best. If you don't know what you wrote, then who else will?


This is my point, I used to scrapes of information I was given and came up with something that works but I don't know how the appvar works, and still do not. I need some more information about why i cant pull the information back out. Was it put in wrong etc.?
I'm trying to say that you didn't put enough effort. Did you read the forums? Did you read the Axe documentation? Did you test it out yourself? I know you definitely didn't do the first two because you really didn't do the last one at all! From some very little experience with Axe, the code looks really wrong to me. Compiling this would not be too pretty. Which leads me to this...


No I will not spend five hours of my day questioning what I wrote. Look at the post above yours and you will see that i cleared up the confusion about what it does.
18 hours? More like 18 seconds or something! ;) Please, please take some time to actually learn Axe. We're not here to teach you Axe. We're here to help you learn Axe. There's a difference: teaching is to actively teach you Axe, while learning is a student and teacher thing. In essence, you must put in effort to learn Axe so that we can help you learn. It's kinda like going to school - the teacher can teach you, but you will only learn if you do your homework! (This is very true, especially in college!) If you learn it, I promise that you will come out knowing Axe much, much better than before! :)

We want to help you. But you must show us that you at least took some time and effort to make your code good so that we can help you better! :D
Title: Re: How does one make an Axe Library, in Axe.
Post by: Streetwalrus on April 17, 2014, 01:49:17 pm
Most if not all of my Axe knowledge is self taught using the documentation or borrowed from other people's ideas I randomly found. You should try that, it'll get you to a very good level. ;)
Title: Re: How does one make an Axe Library, in Axe.
Post by: Hayleia on April 17, 2014, 04:26:54 pm
Also, just a side note. To help everyone (including yourself) understanding your code, you can use self-explanatory names (up to 13 characters) to you labels (and have custom-named variables too but that needs declaration and understanding memory and such), and I think that FAR is far from being self-explanatory (even though the content of the routine is).
Title: Re: How does one make an Axe Library, in Axe.
Post by: josh landers on April 19, 2014, 03:34:06 pm
Edited the other post... sorry for the confusion.