Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: TiAddict on July 28, 2011, 08:46:32 pm

Title: Instring(, and Sub( in Axe
Post by: TiAddict on July 28, 2011, 08:46:32 pm
Can someone show me the routines for them? i tried the ones in the routine section, but it's not working.
Title: Re: Instring(, and Sub( in Axe
Post by: chattahippie on July 28, 2011, 08:59:04 pm
Do you mean how to use them in Axe code or how they are coded in Asm?  I'm sorry, I'm a noob when it comes to programming words and phrases :P 
Title: Re: Instring(, and Sub( in Axe
Post by: BlakPilar on July 28, 2011, 09:04:57 pm
Do you mean how to use them in Axe code or how they are coded in Asm?  I'm sorry, I'm a noob when it comes to programming words and phrases :P 
He's asking for an example method in Axe.
Title: Re: Instring(, and Sub( in Axe
Post by: TiAddict on July 28, 2011, 09:08:23 pm
Well since we cant use instring( command, how should i do it?
Title: Re: Instring(, and Sub( in Axe
Post by: chattahippie on July 28, 2011, 09:13:40 pm
He's asking for an example method in Axe.

Thanks! I don't know how to use Instring(, but for sub(, you use it to create subroutines.

Axe
Code: [Select]
.After you store constants, you create subroutines, like:
sub(AA)
Repeat getKey(15)
.Code code code
sub(AA)
.This executes the subroutine
.code code
End
Return
.The Return ends the program so that the subroutines aren't executed after the Repeat loop ends
Lbl AA
.Code for subroutine
Return
.The label tells the parser where the code for sub(AA) starts, and the Return where it ends

I hope this helps, I know it's a little rough.  I can post something that actually does something, not just a general example if needed.  Good luck, and may the ram clears be few! ;D

EDIT:
I looked around, and for inString(, the synax appears to be inString(BYTE, POINTER) and it "Searches for the byte in the zero-terminated data. If found, it returns the position it was found in (starting at 1). If not found, 0 is returned."
This is strait off of the documentation for every Axe command in the zip with the parser
Title: Re: Instring(, and Sub( in Axe
Post by: TiAddict on July 28, 2011, 09:15:49 pm
haha:) thank you for the command "sub(" in axe, but im asking in Basic to Axe
Title: Re: Instring(, and Sub( in Axe
Post by: chattahippie on July 28, 2011, 09:19:19 pm
Do you mean what does sub( do in Basic?
Title: Re: Instring(, and Sub( in Axe
Post by: Ashbad on July 28, 2011, 09:20:53 pm
Oh, searching for data and getting substrings in axe.  Well, in axe, you can do InData( with.. InData( :P getting a sub string is simple too; just do something like Copy(String+Offset, New_String_malloc, length)
Title: Re: Instring(, and Sub( in Axe
Post by: chattahippie on July 28, 2011, 09:22:46 pm
 Wow... I was off of the question :o

Sorry, I read the question differently.
Title: Re: Instring(, and Sub( in Axe
Post by: TiAddict on July 28, 2011, 09:37:35 pm
I still appreciate trying to help xD
What is "New_String_malloc" Ashbad
Title: Re: Instring(, and Sub( in Axe
Post by: Ashbad on July 28, 2011, 09:48:07 pm
The location where you would be copying the substring to in memory terms.  Just put a pointer to some free chunk of memory there and you'll be set.
Title: Re: Instring(, and Sub( in Axe
Post by: ztrumpet on July 28, 2011, 09:54:08 pm
This may help you with inData (inString): http://ourl.ca/4129/114828
Title: Re: Instring(, and Sub( in Axe
Post by: Runer112 on July 28, 2011, 10:23:14 pm
Here are some implementations I whipped up to act just like the TI-BASIC string functions. The instring function even has the optional third argument! ;D However, note that the substring function should probably not be used to create substrings over 255 characters long, and definitely not 0 characters long. Also, the optional third argument for the instring function should not be longer the length of the string being searched. But other than that, they should work perfectly!

You can get a bit more information about the functions and download the ready-to-go Axe library here (http://ourl.ca/4129/231479).

Code: [Select]
Lbl SUB
 Copy(r?+r?-1,?8000,r?)
  and 0?{r?+?8000}
Return ?8000

Lbl INS
 If -r?
  r?-1
 End
 +r?
Lbl INL
 Return!If {?r?}
 If Equ?String(r?,r?)
  If {}
   r?+1
   Goto INL
  End
 End
Return r?-r?+1
Title: Re: Instring(, and Sub( in Axe
Post by: Deep Toaster on July 28, 2011, 11:22:21 pm
Can someone show me the routines for them? i tried the ones in the routine section, but it's not working.
Taking a stab at it: You might be confused because Axe's inData( takes its arguments in the order exactly opposite that of BASIC's inString(. Byte to search for comes first, then the pointer to the data string.