Can any of you write a program that can take input in the form of a number, ie

Code:
0:Asm(prgmSTREXIST)

that checks to see if the sring of that number exists. If it does, it leaves it alone. If it doesn't, it stores "_" to it. (that was a space, not an underscore.)

Edit: I've seem similar programs written for programs and for pics, so it should be simple to write one for strings.

2nd Edit: I know you can store "" to srings, but I need to use str0="_"
Basically the ASM program just reads the ANS variable (not exactly, but that's pretty much what it does), which is set every time a function or statement returns a value. You can do this with BASIC programs as well just by reading the ANS variable at the beginning of your BASIC program.
swivelgames wrote:
Basically the ASM program just reads the ANS variable (not exactly, but that's pretty much what it does), which is set every time a function or statement returns a value. You can do this with BASIC programs as well just by reading the ANS variable at the beginning of your BASIC program.


Yes, but a BASIC program returns ERR:UNDEFINED if you try to operate on a nonexistant string, which is what I want to remedy, but I don't want to edit whatever is in the string if it happens to exist.

This is what I'm doing:


Code:
Lbl RM
Menu("Recall What? ( )","Kerm's Icons",KI,"Yarnot Icons",YI,"Last Icon Made",LS,"...Back",Z)
Lbl KI
Menu("Recall what? (K)","Folder Icon",FI,"BASIC Icon",BI,"ASM Icon",AI,"ION Icon",II,"DCS Icon",DI,"...Back",RM)
Lbl YI
Menu("Recall What? (Y)","App Icon",PI,"Group Icon",GI,"...Back",RM)
Lbl LS
0:Asm(prgmSTREXIST)
If Str0="_" or length(Str0)!=66:Goto Z
sub(Str0,2,64)->Str3
Goto Y


Working on a DoorsCS program icon editor that works like the Omnicalc Font Editor. The original can be found here.
That would be pretty easy to write; remind me this evening and I'll try to remember to make it.
KermMartian wrote:
That would be pretty easy to write; remind me this evening and I'll try to remember to make it.


Sorry, can't; won't be on. I'll remind you Tuesday evening(?)
Just stole your job, Kerm Razz

http://codeworld.wikidot.com/local--files/random-files/strexist.8xp


Code:
#include "ti83plus.inc"
.org $9d93
.db $bb,$6d

   bcall(_RclAns)
   bcall(_ConvOP1)
   ld a,e
   or a
   jr z,cont
   dec a
   ld (sname+2),a
cont:
   ld hl,sname
   rst 20h
   rst 10h
   jr nc,exists
   xor a
   ld (fpone+2),a
exists:
   ld hl,fpone
   rst 20h
   bcall(_StoAns)
   ret

sname:
.db 4,tvarstrng,tstr0,0

fpone:
.db 0,$80,$10,0,0,0,0,0,0,0,0



(Yeah, I know it could probably have been shorter, but I don't care)


EDIT: Oh yeah, this just returns 1 if strX exists, 0 otherwise
@Xeno

1) Don't store everything in strings. They WILL be overwritten. At the very least use substring(. Better yet, use substring( and put the single "master" string in a safe place, using the likes of Celtic2/3 to tuck it into a program file or appvar. You could also turn it into a list...

2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:THEN:Goto Z: End" is evil.

3) You could also use lists instead of strings. Say your program generates a list of size x, where x is variable. You could create 1 list of {x}, and then another list of size x. This way, at the start of your program, just create a list of size 1, and check the value of the first element to get the number of element is your "main" list. More importantly, if that number is 0, your "main" list does not exist.

*EDIT*
Part 2 fixed
rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.


Explain.

*EDIT*
You still need to re-word part 2.
Thanks Mapar! That was more or less what I was going to be writing anyway. Very Happy
Quote:

rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.


Explain.

*EDIT*
You still need to re-word part 2.


You should avoid using a goto inside of a conditional because it causes memory leaks which eat up some of your ram every time you run the program until you reset the ram.....which is bad....
lindenk wrote:
Quote:

rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.


Explain.

*EDIT*
You still need to re-word part 2.


You should avoid using a goto inside of a conditional because it causes memory leaks which eat up some of your ram every time you run the program until you reset the ram.....which is bad....


How else will you handle program control in a procedural programming language such as TI-BASIC?
Ultimate Dev'r wrote:
lindenk wrote:
Quote:

rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.


Explain.

*EDIT*
You still need to re-word part 2.


You should avoid using a goto inside of a conditional because it causes memory leaks which eat up some of your ram every time you run the program until you reset the ram.....which is bad....


How else will you handle program control in a procedural programming language such as TI-BASIC?



I'm not sure, that's one reason why I learned asm

I wonder if this would work...

Code:

If a=1:then
(some code here)
goto 1
End
If 0=1:then
lbl 1
End


I'm pretty sure the reason it causes memory leaks is the lack of an end after an if since the program would skip over it

Edit: Typo
lindenk wrote:
Ultimate Dev'r wrote:
lindenk wrote:
Quote:

rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.


Explain.

*EDIT*
You still need to re-word part 2.


You should avoid using a goto inside of a conditional because it causes memory leaks which eat up some of your ram every time you run the program until you reset the ram.....which is bad....


How else will you handle program control in a procedural programming language such as TI-BASIC?



I'm not sure, that's one reason why I learned asm

I wonder if this would work...

Code:

If a=1:then
(some code here)
goto 1
End
If 0=1:then
lbl 1
End


I'm pretty sure the reason it causes memory leaks is the lack of an end after an if since the program would skip over it

Edit: Typo


If you have the "End" after a branch and "End" never "executes", then it'll be a memory leak as each time that block of code is executed and branched out of said block, the "End" will never be released from memory; do this enough times and you'll run out of mem. This is why rthprog changed it from
rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:Goto Z" is evil.
to
rthprog wrote:
2) Avoid using "Goto" or "Lbl" within a conditional. "If blahblahblah:THEN:Goto Z: End" is evil.
but still needs to change
Quote:
Avoid using "Goto" or "Lbl" within a conditional.
to
Quote:
Avoid using "Goto" or "Lbl" within a conditional in this fashion: If blahblahblah:THEN:Goto Z: End" is evil.
or something similar, as there are legitimate uses for using "Goto" and "Lbl" statements for branching within a conditional.

Take a look at this site to better understand flow control of TI-BASIC: http://tibasicdev.wikidot.com/controlflow
Which is why I utilize While loops to move around programs and games, so much cleaner.

As to the icon editor.. if there is a good one right there, and mine that can be used as well, why do we need another? Just asking. =]
tifreak8x wrote:
Which is why I utilize While loops to move around programs and games, so much cleaner.

As to the icon editor.. if there is a good one right there, and mine that can be used as well, why do we need another? Just asking. =]


Two reasons:

1.) when I wrote my original, I didn't know that yours existed.
2.) I like the way the Omnicalc Font Editor handles sprites, so I wrote mine to mimic that.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement