Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
Axe
(Moderator:
Runer112
) »
subroutines
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: subroutines (Read 4399 times)
0 Members and 1 Guest are viewing this topic.
MRide
LV8
Addict (Next: 1000)
Posts: 711
Rating: +14/-0
You can't see this.
subroutines
«
on:
July 16, 2010, 12:35:21 pm »
In Axe, is it possible for a program to call itself?
Maybe put a label at the top of the program, then call it as a subroutine?
ex:
:Lbl AR
Some code
:sub(AR)
Logged
calcdude84se
Needs Motivation
LV11
Super Veteran (Next: 3000)
Posts: 2272
Rating: +78/-13
Wondering where their free time went...
Re: subroutines
«
Reply #1 on:
July 16, 2010, 12:44:59 pm »
Welcome to omnimaga!
That is indeed possible, though I'm curious as to what you'd be using it for. (Just asking)
I recommend you introduce yourself in the
Introduce Yourself
subforum.
Logged
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler
For
"PartesOS links"
:
I'll put it online when it does something.
Quigibo
The Executioner
CoT Emeritus
LV11
Super Veteran (Next: 3000)
Posts: 2031
Rating: +1075/-24
I wish real life had a "Save" and "Load" button...
Re: subroutines
«
Reply #2 on:
July 16, 2010, 01:05:03 pm »
Yes, you can have recursive subroutines! It might not work if you are using more than one argument though because all the subroutines share the same temporary variables, you'd have to allocate memory on the fly using free ram. However, I can't think of a routine that would be faster if done recursively. If you want speed, just do some nested loops. Its possible you can get a smaller size than a regular routine though.
Logged
___Axe_Parser___
Today the calculator, tomorrow the world!
MRide
LV8
Addict (Next: 1000)
Posts: 711
Rating: +14/-0
You can't see this.
Re: subroutines
«
Reply #3 on:
July 16, 2010, 01:41:23 pm »
Thanks. I'm rewriting a BASIC program in Axe, and I can't put the whole section in a loop because the call is inside an if statement. (At least, that's what I remember from programming the game in BASIC.)
Logged
Builderboy
Physics Guru
CoT Emeritus
LV13
Extreme Addict (Next: 9001)
Posts: 5673
Rating: +613/-9
Would you kindly?
Re: subroutines
«
Reply #4 on:
July 16, 2010, 02:36:06 pm »
One thing thats really cool about Axe, is how Goto'ing from inside a while loop or an if statement will *not* create memory leaks, unlike Basic. The only time you have to worry about memory leaks is if you call a subroutine with Sub() and you never Return from it. Out of curiosity, what kind of game are you trying to Port over to Axe?
Logged
MRide
LV8
Addict (Next: 1000)
Posts: 711
Rating: +14/-0
You can't see this.
Re: subroutines
«
Reply #5 on:
July 16, 2010, 07:24:20 pm »
I'm porting a game called Pica-Centro. It's like Master Mind, but with numbers.
So use Goto AR instead of sub(AR)?
That does make more sense.
Logged
calcdude84se
Needs Motivation
LV11
Super Veteran (Next: 3000)
Posts: 2272
Rating: +78/-13
Wondering where their free time went...
Re: subroutines
«
Reply #6 on:
July 16, 2010, 07:59:36 pm »
Well, it depends on what you're doing. If I am correct that you need that statement to restart the game if necessary, then yes, a goto should be more appropriate, as you won't need to go back.
Logged
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler
For
"PartesOS links"
:
I'll put it online when it does something.
MRide
LV8
Addict (Next: 1000)
Posts: 711
Rating: +14/-0
You can't see this.
Re: subroutines
«
Reply #7 on:
July 16, 2010, 08:28:34 pm »
Yes, It is simply a way of returning to the title screen. I won't need to go back. Thanks
Logged
DJ Omnimaga
Clacualters are teh gr33t
CoT Emeritus
LV15
Omnimagician (Next: --)
Posts: 55943
Rating: +3154/-232
CodeWalrus founder & retired Omnimaga founder
Re: subroutines
«
Reply #8 on:
July 19, 2010, 07:00:00 pm »
I'm happy Axe doesn't cause mem leaks when doing this. In my RPGs, I often wanted to go back to the title screen when dying, but I stopped because it caused memory errors. There are workarounds but they are hard to implement in BASIC
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
Axe
(Moderator:
Runer112
) »
subroutines