Author Topic: [TI-Basic] umm... error?  (Read 3929 times)

0 Members and 1 Guest are viewing this topic.

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
[TI-Basic] umm... error?
« on: December 03, 2010, 11:57:25 pm »
Well I guess I must be doing something wrong (other than learning how to work with inString, closing parentheses omission, and 2d strings, and using 2.53MP all at once)

I've been getting very strange errors recently...

Where B=inString(str4,str2) (after modifications (including a couple fPart(s, but it's still a natural number))
Code: [Select]
sub(str4,B,1) ;ERR: DOMAIN, (B=7 and length(str4)=36)
  -----
sub(str4,7,1) ;works fine with no change to the string
  -----
7 -> B
sub(str4,B,1) ;works fine
  -----
int(B -> B
sub(str4,B,1) ;works fine

... And that only happens on the second time through the main loop. (the next line of code is the 'End' for the main loop)

Now, after much work to make my obviously corrupting variables work, (using 'int(', of course) I have hit a brick wall.

Spoiler For Spoiler:
:banghead:

when inString( returns '9', which I then convert to (3,1) (I did say it was a 2d string) I try to do this to it:
Code: [Select]
X+1-6(X=6) -> X
... and nothing happens. (I'm not totally sure that's true, but I do know that there is no writeback if it DOES do something)

Anybody with the slightest idea why this is happening?  Any help will get a nice polyalphabetic encryption program! (btw, this is the only bug left)
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 Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [TI-Basic] umm... error?
« Reply #1 on: December 04, 2010, 12:26:42 am »
Wanna upload the full code?

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: [TI-Basic] umm... error?
« Reply #2 on: December 04, 2010, 02:53:04 am »
Well the problem with the sub( command seems like somewhere you are generating a decimal part and sub( can't have those. It has to be an integer. So I would advise using iPart( instead of int( because it can have weird effects in some situations, I don't remember what they are though.

As for that second thing with the storing to the variable thing I'm not sure I understand what you mean by nothing is happening. Like that one isn't getting stored to the variable when the variable equals six? Or something else?
Spoiler For Spoiler:



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

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: [TI-Basic] umm... error?
« Reply #3 on: December 04, 2010, 11:14:42 am »
Well the problem with the sub( command seems like somewhere you are generating a decimal part and sub( can't have those. It has to be an integer. So I would advise using iPart( instead of int( because it can have weird effects in some situations, I don't remember what they are though.

As for that second thing with the storing to the variable thing I'm not sure I understand what you mean by nothing is happening. Like that one isn't getting stored to the variable when the variable equals six? Or something else?

Well maybe I'll try iPart, but int( seems to work well enough...

What I'm saying is that X does not increment properly (like not at all) when X=3 AND Y=1. works fine in all other cases, including when I do other things to X.

Here's the code (not including the key, I've changed that up with no results) (don't currently have access to a link cable):
Code: [Select]
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->Str3
:"CIPHER-KEY-36-LETTERS+NUMBERS->Str4
:Prompt Str1
:" ->Str5
:For(A,1,length(Str1),2)
:A-1->A
:Repeat B or A=length(Str1)
:A+1->A
:sub(Str1,A,1->Str1
:int(inString(Str4,Str2->B
:If not(B
:Str5+Str2->Str5
:End
:If B
:Then
:A->D
:If A=length(Str1)
:Str1+A->Str1
:A-1->A
:Repeat C or A+2=length(Str1
:A+1->A
:sub(Str1,A+1,1)->Str2
:int(inString(Str4,Str2->C
:End
:If not(C
:Then
:Str1+A->Str1
:int(inString(Str4,"A->C
:End
:int((B-1)/6->T
:int(6fPart((B-1)/6)+1->S
:int((C-1)/6->U
:int(6fPart((C-1)/6)+1->V
:If not(S=U and T=V)
:Then
:If T=V
:Then
:S+1-6(S=6)->S
:U+1-6(U=6)->U
:Else
:If S=U
:Then
:T+1-6(T=5)->T
:V+1-6(V=5)->V
:Else
:S+U->S
:S-U->U
:S-U->S
:End
:End
:6T+S->B
:6U+S->C
:End
:int(B->B
:Str5+sub(Str4,B,1)->Str5
:If A-D<0
:Str5+sub(Str1,D+1,A-D)->Str5
:int(C->C
:Str5+sub(Str4,C,1)->Str5
:End
:End
:Disp Str5

EDIT: just noticed I never use Str3 :P
« Last Edit: December 04, 2010, 11:40:12 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 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: [TI-Basic] umm... error?
« Reply #4 on: December 04, 2010, 11:52:41 am »
iPart( and int( have the same effect for positive numbers, so that's not it. :)

It looks to me like fPart( is not returning the right number.  Try this when it crashes:
Figure out which variable was being used (it's probably the bad one).
Go into the Solver ([Math] [0])
Type that variable into the equation
Scroll up or down (I forget which) and look at all the digits of precision the calc has.  Here you can see what's happening to these numbers.

Fix: put a round(......,0 around the statement with the fpart(.  (Ex: int(6fPart((B-1)/6)+1->S changes to round(6fPart((B-1)/6)+1,0->S)
« Last Edit: December 04, 2010, 11:53:12 am by ztrumpet »

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: [TI-Basic] umm... error?
« Reply #5 on: December 04, 2010, 01:03:48 pm »
iPart( and int( have the same effect for positive numbers, so that's not it. :)

It looks to me like fPart( is not returning the right number.  Try this when it crashes:
Figure out which variable was being used (it's probably the bad one).
Go into the Solver ([Math] [0])
Type that variable into the equation
Scroll up or down (I forget which) and look at all the digits of precision the calc has.  Here you can see what's happening to these numbers.

Fix: put a round(......,0 around the statement with the fpart(.  (Ex: int(6fPart((B-1)/6)+1->S changes to round(6fPart((B-1)/6)+1,0->S)

and... what is the difference between int(...) and round(...,0)?  Also, int( did fix my crashing problems.

okay more info on what is going wrong:
Code: [Select]
 if one_number = 9
    that_number=8
    if the_other = 8
      the_other=7
    end
  else
    everything works
  end

and 7 can be a valid #. lulz fun.

PS: what does round(...,0) do? I've always avoided round...
« Last Edit: December 04, 2010, 01:07:14 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 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: [TI-Basic] umm... error?
« Reply #6 on: December 04, 2010, 01:06:21 pm »
round just rounds a number to the decimal places you specify.

Ex:
round(10.999,0) = 11
round(10.9,0) = 11
round(10,0) = 10
round(10.465,1) = 10.5
round(10.2854,3) = 10.285

Int is like round(...,0), but instead of rounding up if it's greater than or equal to .5, it still rounds down. :)

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: [TI-Basic] umm... error?
« Reply #7 on: December 04, 2010, 01:27:28 pm »
 yay!!! it works! :hyper:

but now I'm having problems parsing non-text characters... :(

EDIT: nvm, i fixed it :D Time for extensive testing!

EDIT2: who wants the first shot at cracking it?  
Kz1 pxn lhxm ztkq pf zhmjuewppr vppo ynssp2a.P


EDIT3: attached complete file and a readme  ;D
« Last Edit: December 04, 2010, 02:58:23 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 meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: [TI-Basic] umm... error?
« Reply #8 on: December 04, 2010, 08:11:47 pm »
Ya, basically there are three ways of getting the integer part of a number. Using iPart( is probably the easiest way but has some issues sometimes (I believe). It simply chops off the decimal and gives you the integer. The next way is using int(. This works the exact same as iPart(, but for positive numbers only. This is because it actually always rounds down which means negative numbers will be lower sometimes (-5.4 and -5.6 will both return -6). The third way is using round(. It basically just rounds normally however it has two arguments that determine to what decimal value it rounds to. So if you put zero in the second argument you will just get an integer.

And glad you got things working and such. I'll check things out later when I get some time.
Spoiler For Spoiler:



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

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: [TI-Basic] umm... error?
« Reply #9 on: December 06, 2010, 04:44:47 pm »
wow. found a typo in the decryption code :P
also made a random key generator. (inspired by JustCause's Secure (Ish) Cipher)

this really is a somewhat modified version of the Playfair Cipher. instead of adding an 'X' or 'Q' between two equal letters, I just let them slide through.  This might be a bit of a security concern (although it makes it harder to identify as a playfair cipher), so to make it more secure, you can change that easily or encrypt, add a letter to the beginning, and encrypt again. (or even decrypt :P)

I'm not sure if this really deserves a project thread. I don't really plan on adding much more.

EDIT (before post): wow... I forget to rename the readme and get an error... then I fix it, it says I've already posted.  I go and look at it, there is no post there. I re-open the reply page, copy & paste the text and reselect the files (none of which have the same name as any others on this thread) and... it says there is already a file with that name. :banghead:
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: [TI-Basic] umm... error?
« Reply #10 on: December 06, 2010, 07:04:43 pm »
file names are forum-wide. Also when a file name has been used once the name cannot ever be used again, even if the file is deleted. It's retarded that SMF removed the ability to have duplicate file names...