Author Topic: Fun with strings!  (Read 8294 times)

0 Members and 1 Guest are viewing this topic.

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Fun with strings!
« on: December 14, 2010, 11:45:12 pm »
Y DUZ DIS GIB M3 A 3R0R? :banghead:

Code: [Select]
:If sub(Str1,1,1)="""
:Then
...
:End

Spoiler For edit:
I DO want all three quotes there. It worked fine with Str0, and that's what [RCL][VARS][7][0] spits out.
« Last Edit: December 14, 2010, 11:48:39 pm by lookitsan00b »
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fun with strings!
« Reply #1 on: December 14, 2010, 11:52:14 pm »
Sadly TI-BASIC doesn't support that. It gives an error because the parser is designed to think that the second quote ends the string, so it sees the third one as a Syntax error. The only way to display quotes is to use Input function and type a quote, stored in a string variable, and have the person using your program send that string to his calc along with your program. Otherwise, if you use Text( you just have to use two ' characters.
« Last Edit: December 14, 2010, 11:53:02 pm by DJ Omnimaga »

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: Fun with strings!
« Reply #2 on: December 14, 2010, 11:56:15 pm »
 :'(

is there any other way to check if the contents of a string would evaluate to a string (preferably not involving errors)?
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fun with strings!
« Reply #3 on: December 15, 2010, 12:05:17 am »
What do you mean? I don't understand what you're asking for really.

But ya, as DJ said you can't have a quotation mark inside of a string unless you do a lot of tricks.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Fun with strings!
« Reply #4 on: December 15, 2010, 12:06:01 am »
Or use Assembly  ;)

*DJ, Not saying that anyone needs to learn ASM.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fun with strings!
« Reply #5 on: December 15, 2010, 12:08:44 am »
Yeah I know. Sadly I think ASM (or Axe?) is the only way to force the storage of a string quote character in a string.

I wonder about STO...

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: Fun with strings!
« Reply #6 on: December 15, 2010, 12:12:37 am »
basically, I'm doing:

Code: [Select]
:input Str1,""
:Str1->u           //thats the graphing variable

Ok, so now I need to know what data type u is. I have tests for everything but strings.

EDIT: Na. I wanna save all my assembly routines for blocking ON, APPS, and [2nd][Quit] :P
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fun with strings!
« Reply #7 on: December 15, 2010, 12:17:24 am »
So you want to test a string if it is a string, number, list, matrix, or something else?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Fun with strings!
« Reply #8 on: December 15, 2010, 12:19:04 am »
U is a numeric variable. It can hold any numeric value... but not much else. You can use the ANS variable if you want, though. It will hold any normal type variable you care to use. If you want to test for variable type without errors, you're most likely going to be forced into using Assembly, which makes it fairly trivial.
« Last Edit: December 15, 2010, 12:20:20 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Fun with strings!
« Reply #9 on: December 15, 2010, 09:29:54 am »
Yeah I know. Sadly I think ASM (or Axe?) is the only way to force the storage of a string quote character in a string.

I wonder about STO...
I believe it's possible to store a " inside a string if it's typed into the homescreen, recalled to the Y= editor, and then stored in a string from either the homescreen or a TI-BASIC program.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Fun with strings!
« Reply #10 on: December 15, 2010, 09:41:36 am »
I think it's mentioned on TIBD somewhere...
here: http://tibasicdev.wikidot.com/strings
It's listed under the "Advanced" heading. =)

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: Fun with strings!
« Reply #11 on: December 15, 2010, 09:53:00 am »
I know its possible to do that, it's also really easy to just do :Input Str1 and type in a double quote... but I don't want to have to include the string with the program.

And yes, u IS a graphing variable. [2nd][7]. try it.

I'm storing the string to that, then getting the answer right back from it. All its doing for me is converting the string from Input into the corresponding data type.

So you want to test a string if it is a string, number, list, matrix, or something else?

Exactly.
« Last Edit: December 15, 2010, 09:54:49 am by lookitsan00b »
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Fun with strings!
« Reply #12 on: December 15, 2010, 10:27:13 am »
:'(

is there any other way to check if the contents of a string would evaluate to a string (preferably not involving errors)?

ya, you could use '' instea of "   ....
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

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: Fun with strings!
« Reply #13 on: December 15, 2010, 10:48:10 am »
He wants to check if it contains the " token, though, to see if Str1 contains a string within the string, so '' wouldn't work.

I don't think it's possible, except for that Y= trick, unfortunately.




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fun with strings!
« Reply #14 on: December 15, 2010, 02:55:50 pm »
What Deep Thought said. You'll have to use some Axe or assembly otherwise, I'm afraid. The TI-OS has some weird limitations sometimes. Another example is how the Sto char cannot be used inside strings at all, even through Y= and Input...