[TI BASIC] Subroutines and unarchiving in BASIC
Moderator: MaxCoderz Staff
[TI BASIC] Subroutines and unarchiving in BASIC
Is there any way to archive/unarchive BASIC programs on the calculator from a BASIC program?
Also, If I want to use subroutines in a program, do I have to make a new program to contain each subroutine?
I am working on adapting an old BASIC adventure game skeleton to TI basic as you can read in the announcing projects forum.
Edit kv83: Added tag.
Also, If I want to use subroutines in a program, do I have to make a new program to contain each subroutine?
I am working on adapting an old BASIC adventure game skeleton to TI basic as you can read in the announcing projects forum.
Edit kv83: Added tag.
Last edited by CompWiz on Fri 21 Oct, 2005 2:13 am, edited 1 time in total.
In Memory of the Maxcoderz Trophy
Re: Subroutines and unarchiving in BASIC
Well there is to ways you can do thisCompWiz wrote:Is there any way to archive/unarchive BASIC programs on the calculator from a BASIC program?
Also, If I want to use subroutines in a program, do I have to make a new program to contain each subroutine?
I am working on adapting an old BASIC adventure game skeleton to TI basic as you can read in the announcing projects forum.
-Use zcopy to copy the program into a new one called ztemp
Or
-Run the program directly from the archive using flash Gordon (which is the best option IMO.
As for the sub routine, you make the sub in a new program and when you want to use it you just call the prgm in the main one.
Code: Select all
Example:
MAIN
:Pause "Hi Where Is Sub?
:prgmSUB
:Pause "There It Is!
SUB
:Pause "I'm Right Here ^.^
So you run prgmMAIN and it displays "Hi Where Is Sub?", then you press enter. It calls prgmSUB and it displays "I'm Right Here ^.^", then you press enter. Now it returns to prgmMAIN, and displays "There It Is!".
Sorry if you understand this already, but if not I hope this makes sense :D.
Yes, I know how to use programs as subroutines, but I was hoping to not have a whole lot of little subroutine programs. Thanks for the help with archiving.
Last edited by CompWiz on Fri 21 Oct, 2005 2:17 am, edited 1 time in total.
In Memory of the Maxcoderz Trophy
-
- Calc Wizard
- Posts: 501
- Joined: Sat 28 May, 2005 5:34 am
- Location: Chesapeake, Virginia
- Contact:
Trick the basic interpreter into executing code in a for loop and return when it hit's the end. This might leak ram, I dunno. I've done it before. Something like:
Something like that...
Code: Select all
for (a,0,1)
If A
Goto Z
End
...
Code: Select all
Lbl Z
<sub code>
End
Yeah it leaks pretty bad, but well just check UTI for that topic.
http://www.unitedti.org/index.php?showtopic=3629
http://www.unitedti.org/index.php?showtopic=3629
Yeah, I read that post on UTI a few days ago. I don't want my program to grind to a halt after a little while.
Another question, is there any way to package several programs into a group and then have a basic program ungroup them when it is used? Also, is there any way to delete programs in basic?
Another question, is there any way to package several programs into a group and then have a basic program ungroup them when it is used? Also, is there any way to delete programs in basic?
Last edited by CompWiz on Fri 21 Oct, 2005 2:18 am, edited 1 time in total.
In Memory of the Maxcoderz Trophy
-
- Calc Wizard
- Posts: 501
- Joined: Sat 28 May, 2005 5:34 am
- Location: Chesapeake, Virginia
- Contact:
Oops, that should be not(a instead of A (test if it equals zero not one ).
Indeed, it leaks tremoundously. I had found away to do it without them- wish I could remember .
And yes, I know what leaks are and how they occur.
PS: Want to see a easy example of what leaks can do?
Note the initial speed, then let it run for about two minutes. If you haven't recieved an 'Error! Memory' message by then; you'll at least notice the crawl it has been reduced too
Indeed, it leaks tremoundously. I had found away to do it without them- wish I could remember .
And yes, I know what leaks are and how they occur.
PS: Want to see a easy example of what leaks can do?
Code: Select all
Lbl 0
For(A,0,1
If not(A
Goto Z
End
Disp "Bye
Goto 0
Lbl Z
Disp "Hi
End
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
Not sure if this has been brought up due to this topic appearing everywhere on various forums/threads, but I used a technique I found on ticalc.org ('cause I didn't want to think of one myself):
http://www.ticalc.org/archives/files/fi ... 14542.html
Considering its age (Sat Sep 2 19:36:55 2000! ), it was (or may still be) pretty "advanced" concepts
http://www.ticalc.org/archives/files/fi ... 14542.html
Considering its age (Sat Sep 2 19:36:55 2000! ), it was (or may still be) pretty "advanced" concepts
"If SOURCE is outlawed, only outlaws will have SOURCE."
That looks like a good document(expecially for me, as I am terrible at optimizing for speed and size). I'm not sure if that method for subroutines will work for what I am doing, but I'll look into it. Thanks for all the help!
Last edited by CompWiz on Fri 21 Oct, 2005 2:18 am, edited 1 time in total.
In Memory of the Maxcoderz Trophy
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
A good document, but outdated - there are many more known ways to optimize now. Example:
then wrote:{Ans,0
While Ans(1
{Ans(1)-1,Ans(2)+1/(4Ans(1)-3)-1/(4Ans(1)-1
End
Disp Ans
now wrote:{Ans,0
While Ans(1
Ans-{1,2/(16Ans(1)^2+8Ans(1)-3
End
max(Ans
Last edited by DarkerLine on Fri 21 Oct, 2005 12:44 pm, edited 1 time in total.