Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Happybobjr on November 13, 2010, 09:06:44 pm

Title: [Project] Auto-Organize Program
Post by: Happybobjr on November 13, 2010, 09:06:44 pm
AutOrganize Version: 0.6  ;D(http://www.omnimaga.org/Themes/default/images/gpbp_arrow_up.gif)
Description: this program will organize your axe programs by block method.

Features:
* Organizes your axe program. (see screeny)
* Ignores spaces in your code for better organization. (see screeny)
* Exact size on output program that is needed. (see screeny Cool )
* copies notes evend if they have if or while etc. in it.
* Does not add spaces to notes.
* Spaces within notes are not deleted

Wishlist:
* Choose the program to organize (it currently must be called a1xtest)
* Reject nonAxe programs.
* Warn you if not enough ram.  Will also inform you of the amount of ram needed. (about to finish)
* Have the new program replace the old unorganized one.
*if/while etc. statements in a string are ignored

Warning: this is still an early version so bugs may occur although only one has been found.
Bugs:
* Example Output(1,1,"hi i am james")
-will become Output(1,1,"hiiamjames")



Credits:
DJ Omnimaga: For hosting this wonderful site.
Builderboy: Assistance in program size. Also inspired this project with his auto-optimization program.
FinaleTI: Linking me to code for free ram left.

Note:  sorry i have been a little short tempered latly. I have been on a ton of deadlines between my computer and school work.

Organize=compiled
a1xtest=test program


(http://www.omnimaga.org/index.php?action=dlattach;topic=5311.0;attach=4489;image)

V Old V
Spoiler For Spoiler:
Remember Auto-optimize prog?

I was thinking as many of us are quite bad at code organization.... that someone could make an auto-organiser prog.

Basically it would do this.

Before V

:.Axample
:While 1
:If Getkey=15
:Return
:End
:For(A,0,50)
:Output(A^16,A^7,A>Dec)
:End
:End


After V

:.Axample
:While 1
: If Getkey=15
:  Return
: End
: For(A,0,50)
:  Output(A^16,A^7,A>Dec)
: End
:End



A cool feature would also be to reconize ax programs from ti-basic programs.
That way it would know how to deal with the "Then" comand.
Title: Re: [Request]
Post by: yunhua98 on November 13, 2010, 09:08:34 pm
this would have to be done in ASM then, i guess? since Axe can't write to programs
Title: Re: [Request]
Post by: Happybobjr on November 13, 2010, 09:09:58 pm
this would have to be done in ASM then, i guess? since Axe can't write to programs

nope,  auto optimization was written in axe. (i think)
Anyways, go find my "drawing to basic"  it writes to programs.

Edit: might have seemed rude depending where you live.
Title: Re: [Request]
Post by: Builderboy on November 13, 2010, 09:15:44 pm
My question is how are you going to run the program after you add in the spaces?  And the only reason the AutoOptimization program is able to edit programs is because it never *increases* the file size, which is incredibly difficult.
Title: Re: [Request]
Post by: nemo on November 13, 2010, 09:18:03 pm
My question is how are you going to run the program after you add in the spaces?  And the only reason the AutoOptimization program is able to edit programs is because it never *increases* the file size, which is incredibly difficult.

as the program runs, count the number of spaces you add in.
after you're done, create a temporary appvar. copy all the data from the program you edit to the appvar.
then, create the same program variable that you edited with its original size, plus the amount of spaces you added in.
copy appvar data to the program variable.
Title: Re: [Request]
Post by: Builderboy on November 13, 2010, 09:26:37 pm
But with that, i need at least half of my ram free, and so programs that take up more than half of RAM (excluding the organization program) won't work
Title: Re: [Request]
Post by: nemo on November 13, 2010, 09:42:15 pm
hmmm.. do it in segments?

do 1/5 of the program, make an Appv TEMP1, copy 1/5 of the new program's data to TEMP1, archive it.
repeat for TEMP2, TEMP3, TEMP4, TEMP5.
copy each appvar to the new Program variable separately.. you get the idea.

the problem with that is it 1) it'll take forever due to the archiving and 2) frequent use will wear out the archive.

so, another suggestion, loop through the program data calculating how many spaces you need to add in.
create a temp appvar with enough space to compensate for the extra bytes.
loop through again, this time copying the program data to L3, adding in spaces as necessary. once you reach 768 bytes, copy the L3 data to the new appvar
repeat until all the data is copied.
transfer the appvar to the program var
delete the appvar.

i know, it doesn't solve the  memory problem. but cmon. just put a note in the readme to have:
2 * [program_size] + [autoOp_program_size] +[arbitrary_number_like_1000] bytes available in ram.
Title: Re: [Request]
Post by: Happybobjr on November 13, 2010, 09:50:43 pm
But with that, i need at least half of my ram free, and so programs that take up more than half of RAM (excluding the organization program) won't work

true.
But USPRES only takes up 11k bytes of ram.  And that is one of the largest ti-basic programs.
As long as your program doesn't go over 10k bytes, everything should be fine.
You could check the ammount of free ram left and give an Error: Not Enough Memory  if it would require to much.

I would think it would be worth making.  I will try in a couple of weeks if i can ever hook my calc to a computer again. (and steal you code for detecting programs ;) )

But overall I would think if you took a few parts of auto-optimisation program, It would be very simple to make.

Ninja'd
@nemo:  Most people if making a large program, won't have all the code in the one prog.  Most will have large parts seperated such as a menu, game, help
Title: Re: [Request]
Post by: Builderboy on November 14, 2010, 12:28:12 am
So are you planning to use spaces or some other token for the indent?  Colons i think would work the best because then the program would still execute, while any other would cause errors.

Also, there is an alternative method for allocating memory using numerous OS BCALLS that would move the program around and extend free memory so that the program could grow normally, but i would not be the one to ask on how to use that D:
Title: Re: [Request]
Post by: squidgetx on November 14, 2010, 10:31:14 am
So are you planning to use spaces or some other token for the indent?  Colons i think would work the best because then the program would still execute, while any other would cause errors.


Aren't spaces ignored by the parser?
Title: Re: [Request]
Post by: FinaleTI on November 14, 2010, 10:42:12 am
So are you planning to use spaces or some other token for the indent?  Colons i think would work the best because then the program would still execute, while any other would cause errors.


Aren't spaces ignored by the parser?
What would be cool is if it detected it was an Axe source program, it used spaces, but if it was a BASIC program, it would use colons.
Title: Re: [Request]
Post by: Deep Toaster on November 14, 2010, 11:14:34 am
So are you planning to use spaces or some other token for the indent?  Colons i think would work the best because then the program would still execute, while any other would cause errors.

Also, there is an alternative method for allocating memory using numerous OS BCALLS that would move the program around and extend free memory so that the program could grow normally, but i would not be the one to ask on how to use that D:

Actually, InsertMem and DeleteMem don't need the edit buffer and rearrange everything for you, except the size bytes for some reason. They's really convenient for this, just a bit slow.

Just thought of a way to do this with pure Axe, though: allocate however many bytes the program is for a temporary program (since the spaces/colons can only add to the size), then when it's filled up, archive it, create a program with 1000 more bytes than before, copy it from archive, delete the archived copy, and repeat. It should be pretty simple since it's not too complicated to check for loops. I think colons should be used for BASIC and spaces for Axe, though. It adds to the difference between the two, which would be convenient.
Title: Re: [Request]
Post by: Happybobjr on November 14, 2010, 12:31:24 pm
except i would still like to steal builderboys auto optimize source ;).  and with no connection from calc to pc....
Title: Re: [Request]
Post by: Builderboy on November 14, 2010, 02:32:01 pm
Go ahead and use it as you will, i have no problem with it ^^ open it up in sourcecoder if you want to see how it works
Title: Re: [Request]
Post by: Happybobjr on November 15, 2010, 07:51:46 am
I don't have connection to my pc with the issues its having......

might be a couple weeks before i can do anything...
Title: Re: [Request]
Post by: Happybobjr on November 15, 2010, 09:10:07 pm
Ok I have about 20 min to write this before my graphics card fan turns off.

I made it ;)

AutOrganize Version: 0.5

Description: this program will organize your axe programs by block method.

Features:
* Organizes your axe program. (see screeny)
* Ignores spaces in your code for better organization. (see screeny)
* Exact size on output program that is needed. (see screeny 8) )

Wishlist:
* Choose the program to organize (it currently must be called a1xtest)
* Reject nonAxe programs.
* Warn you if not enough ram.  Will also inform you of the amount of ram needed.
* Have the new program replace the old unorganized one.

Credits:
DJ Omnimaga: for hosting this wonderful site.
Builderboy: assistance in program size. Also inspired this progect with his auto-optimization program.

turns out it is still buggy and i shall not post screeny tonight... sorry.
contact me if you want to help me with my code.  It probably only has 1 small error.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 11:27:06 am
Ok, right now i am really frusterated with my program right now.

does anyone know how i can find the length of a program?
length command doesn't seem to work
Title: Re: [Request]
Post by: Builderboy on November 16, 2010, 12:15:35 pm
If the pointer to your program is P, the length is {P-2}r
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 12:23:50 pm
really why is that?

thanks.
Title: Re: [Request]
Post by: Builderboy on November 16, 2010, 12:27:29 pm
The length to programs is stored at the very beginning of ever program and appvar :) the pointer seems to point to the actual program data and not the length before it.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 12:35:53 pm
oh, ok thank you so much.
It works and once i understand how to rip apart your programs menu, i shall have a version 1.0 :)

Any assistance on that :P

Edit:  It would also be great to know the asm code for ram availble.
Title: Re: [Request]
Post by: FinaleTI on November 16, 2010, 03:38:13 pm
Edit:  It would also be great to know the asm code for ram availble.
There's a link to Axe code to it in the routines thread.
Here (http://ourl.ca/4129/94067) it is.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:22:36 pm
AutOrganize Version: 0.6  ;D(http://www.omnimaga.org/Themes/default/images/gpbp_arrow_up.gif)
Description: this program will organize your axe programs by block method.

Features:
* Organizes your Axe program. (see screeny)
* Ignores spaces in your code for better organization. (see screeny)
* Exact size on output program that is needed. (see screeny Cool )
* copies notes even if they have if or while etc. in it.
* Does not add spaces to notes.
* Spaces within notes are not deleted

Wishlist:
* Choose the program to organize (it currently must be called a1xtest)
* Reject non-Axe programs.
* Warn you if not enough ram.  Will also inform you of the amount of ram needed. (about to finish)
* Have the new program replace the old unorganized one.
*if/while etc. statements in a string are ignored

Warning: this is still an early version so bugs may occur although only one has been found.
Bugs:
* Example Output(1,1,"hi i am james")
-will become Output(1,1,"hiiamjames")
* T END or such will still be an end...



Credits:
DJ Omnimaga: For hosting this wonderful site.
Builderboy: Assistance in program size. Also inspired this project with his auto-optimization program.
FinaleTI: Linking me to code for free ram left.


Organize=compiled
a1xtest=test program
Title: Re: [Request]
Post by: DJ Omnimaga on November 16, 2010, 04:24:55 pm
Great job! Does it works with extremly large programs too?
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:25:19 pm
as long as it doesn't use more ram than you have.

Note: could someone plz change the topic name to "[Project] Auto-Organize Program" ?
Title: Re: [Request]
Post by: Deep Toaster on November 16, 2010, 04:46:29 pm
Nice! This will be useful for Axe programmers...

Will it take away extra spaces as well?
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:47:39 pm
spaces within the code will be removed before added in.
Spaces with a note (. statement)  will not be removed.

Does that answer what you are asking?
Title: Re: [Request]
Post by: JustCause on November 16, 2010, 04:48:09 pm
That's neat! Will download as soon as I can.

Unrelated: what are you using that gave you the single-line scrolling? Is that OS 2.54 or something else?
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:48:55 pm
os 2.53 MP

i would downgrade, but i really don't want to bother ;)
Title: Re: [Request]
Post by: Deep Toaster on November 16, 2010, 04:50:05 pm
Quote from: happybobjr
spaces within the code will be removed before added in.
Spaces with a note (. statement)  will not be removed.

Does that answer what you are asking?

Yep, that's great. As a suggestion, maybe have it only remove leading spaces?
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:50:29 pm
leading spaces?
Title: Re: [Request]
Post by: Deep Toaster on November 16, 2010, 04:51:59 pm
Yeah, only spaces that come right after a newline.

That way, stuff like COMMAND(ARG, ARG) would be left the same.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:52:59 pm
still confused.  Arg,arg ?

edit: oh are you talking about lines that wrap around to a new line but are still the same line?
Title: Re: [Request]
Post by: ASHBAD_ALVIN on November 16, 2010, 04:53:32 pm
argument 1 and argument 2.  like text(x,y
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:55:07 pm
why would those be affected?

i am throughly confused.
Title: Re: [Request]
Post by: Deep Toaster on November 16, 2010, 04:55:15 pm
I mean how some people like to add spaces for padding between arguments in a line. I'm suggesting an added check to see if the spaces are at the beginning of the line before removing them, which would take care of the string bug as well :)
Title: Re: [Request]
Post by: ASHBAD_ALVIN on November 16, 2010, 04:55:58 pm
I never have heard of spaces between args, though I do think it's possible.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:56:21 pm
oh, ok, never thought about that ;)

quick question.  why would you have COMMAND(ARG,   ARG) ?
Title: Re: [Request]
Post by: ASHBAD_ALVIN on November 16, 2010, 04:57:08 pm
I don;t know, weird to me lol :P

I would never use that, as I try to make lines as short as possible.
Title: Re: [Request]
Post by: nemo on November 16, 2010, 04:58:13 pm
i guess it's a programmer's choice.
regardless, the string bug could easily be handled with this pseudocode:

Code: [Select]
if read_byte == quotation_token
repeat read_byte == quotation_token
read_byte = next_byte
end
end

that way, it ignores everything within quotations.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 04:58:19 pm
my pc seems like it will shut down soon.  Just a warning.

Nemo: i am going to use deep thoughts code ;)
Title: Re: [Request]
Post by: SirCmpwn on November 16, 2010, 04:58:41 pm
So, I understand why you would leave this:
Code: [Select]
While 1
 If 1
.Note
 End
End
Like it is, but is this:
Code: [Select]
While 1
 If 1
.  Note
 End
End
A possibility?
Or perhaps this:
Code: [Select]
While 1
 If 1
..Note
 End
End
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 05:00:34 pm
i suppose,  but why would you want that?


either way,  That would be under Options:  which i will add once i rip apart Builderboy's code for program menus.


my graphics card fan is about to shut off.

Title: Re: [Request]
Post by: SirCmpwn on November 16, 2010, 05:01:22 pm
It makes it easier to see where the comments lie, especially deep into methods.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 05:02:37 pm
oh ok,  for the future i suppose. 
Title: Re: [Request]
Post by: nemo on November 16, 2010, 05:02:47 pm
it's all programmer's choice, here. personally, i don't understand why you would even indent on calculator source code. i don't even comment on my source for calculators.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 05:03:26 pm
It makes it easier for people to understand their or someone else's code.
Title: Re: [Request]
Post by: SirCmpwn on November 16, 2010, 05:03:27 pm
Also, speaking of menus, I have a routine that will display a custom menu in the same style that TIOS uses.  I just need to figure out a way of getting it off my calculator.
Also, I personally don't indent my code, but I comment a lot on the more complex stuff.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 05:09:04 pm
I figured if you had a program to do it for you, why not? ;)
Title: Re: [Request]
Post by: Deep Toaster on November 16, 2010, 06:55:48 pm
i suppose,  but why would you want that?


either way,  That would be under Options:  which i will add once i rip apart Builderboy's code for program menus.


my graphics card fan is about to shut off.



Mostly it's just that a lot of programmer like to treat If  statements as blocks (since that's kinda what they are). Ends are much easier to debug that way.
Title: Re: [Request]
Post by: Happybobjr on November 16, 2010, 07:16:23 pm
well thats the way it organizes.
Title: Re: [Request]
Post by: DJ Omnimaga on November 16, 2010, 10:36:41 pm
it's all programmer's choice, here. personally, i don't understand why you would even indent on calculator source code. i don't even comment on my source for calculators.
Yeah it depends of people. Personally i don't bother. I just add more linebreaks between parts of code. I try to add some comments if I fear I will forget what something does, though. Otherwise I end up having to rewrite lots of things, like with Metroid II: Evolution 4 years ago. X.x
Title: Re: [Project] Auto-Organize Program
Post by: Happybobjr on November 17, 2010, 06:52:11 am
it's all programmer's choice, here. personally, i don't understand why you would even indent on calculator source code. i don't even comment on my source for calculators.
Yeah it depends of people. Personally i don't bother. I just add more linebreaks between parts of code. I try to add some comments if I fear I will forget what something does, though. Otherwise I end up having to rewrite lots of things, like with Metroid II: Evolution 4 years ago. X.x

people not bothering is why i made it ;)
now instead of 5-45 min of organizing, it will take 30 sec.

(it will still be used by me ;))
Title: Re: [Project] Auto-Organize Program
Post by: Deep Toaster on November 17, 2010, 10:37:13 am
Quote from: happybobjr
it's all programmer's choice, here. personally, i don't understand why you would even indent on calculator source code. i don't even comment on my source for calculators.
Yeah it depends of people. Personally i don't bother. I just add more linebreaks between parts of code. I try to add some comments if I fear I will forget what something does, though. Otherwise I end up having to rewrite lots of things, like with Metroid II: Evolution 4 years ago. X.x

people not bothering is why i made it ;)
now instead of 5-45 min of organizing, it will take 30 sec.

(it will still be used by me ;))

And I'll be using it too :D Good luck.
Title: Re: [Project] Auto-Organize Program
Post by: Munchor on November 17, 2010, 12:42:57 pm
That would be cool, since I never organize my scripts, they are always a mess!
Title: Re: [Project] Auto-Organize Program
Post by: DJ Omnimaga on November 17, 2010, 03:08:26 pm
Yeah I might start using it too for some projects.
Title: Re: [Project] Auto-Organize Program
Post by: Builderboy on November 18, 2010, 01:28:42 am
Sweet ^^ I would have started indenting my programs a long time ago, but the main reason i don't is because of screen space :( Maybe this combined with a small font editor would be epic!
Title: Re: [Project] Auto-Organize Program
Post by: Happybobjr on November 18, 2010, 10:42:02 am
you can edit your font?

or are you saying a code editor with small characters?... humm that does sound like a good idea... 

EDIT: i am going to tear this down and start over.
        I really hate how i dealt with ignoring spaces within comments.


In new version I am planning on rewriting how i do my space ignoring.

Edit:  I will be a while on an update.
Title: Re: [Project] Auto-Organize Program
Post by: Builderboy on November 18, 2010, 07:08:05 pm
Yeah, an editor in the small font would be awesome ^^ I kinda have one in development, but progress is slow
Title: Re: [Project] Auto-Organize Program
Post by: Happybobjr on November 18, 2010, 09:07:31 pm
i might halt my work on this and work on that ^ ;).
Truthfully it might not be to extremely difficult

In Japanese class for the next 3 days, we are watching spirited away.
Depending on the amount of light... I could try this.

Anyone know if there is some sort of command or anything that will tell you the size of a charctor?
i.e.  prgm=4  unarchive=9
I could use output with small font maybe...