Author Topic: Instring(, and Sub( in Axe  (Read 4943 times)

0 Members and 1 Guest are viewing this topic.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Instring(, and Sub( in Axe
« 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.

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #1 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 

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #2 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.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #3 on: July 28, 2011, 09:08:23 pm »
Well since we cant use instring( command, how should i do it?

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #4 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
« Last Edit: July 28, 2011, 09:17:50 pm by chattahippie »

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #5 on: July 28, 2011, 09:15:49 pm »
haha:) thank you for the command "sub(" in axe, but im asking in Basic to Axe

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #6 on: July 28, 2011, 09:19:19 pm »
Do you mean what does sub( do in Basic?

Ashbad

  • Guest
Re: Instring(, and Sub( in Axe
« Reply #7 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)
« Last Edit: July 28, 2011, 09:21:11 pm by Ashbad »

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #8 on: July 28, 2011, 09:22:46 pm »
 Wow... I was off of the question :o

Sorry, I read the question differently.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #9 on: July 28, 2011, 09:37:35 pm »
I still appreciate trying to help xD
What is "New_String_malloc" Ashbad
« Last Edit: July 28, 2011, 09:45:59 pm by TiAddict »

Ashbad

  • Guest
Re: Instring(, and Sub( in Axe
« Reply #10 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.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #11 on: July 28, 2011, 09:54:08 pm »
This may help you with inData (inString): http://ourl.ca/4129/114828

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Instring(, and Sub( in Axe
« Reply #12 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.

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
« Last Edit: July 28, 2011, 10:33:10 pm by Runer112 »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Instring(, and Sub( in Axe
« Reply #13 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.