Search code examples
ti-basic

Is there something I'm doing wrong to pick up this error?


I am new to Ti-basic, and I am trying to code it. I'm trying to make this 'special type of input' program. It is kind of like input, but it will show the word as it is being pressed (and there is no need to put in alpha)

Here is the code so far that I believe is pertaining to the error

:{41,42,43,51,52,53,54,55,61,62,63,64,65,71,72,73,74,75,81,82,83,84,85,91,92,93,94,102,103,103}→∟KEYS
:"ABCDEFGHIJKLMNOPQRSTUVWXYZθ :?"→Str7
:0→K
:""→Str1
:
:Repeat K=105
:getKey→K
:If max(∟KEYS-K)
:prgmFINDIND
:.........
:End

Inside prgmFINDIND, This is the code

:1+sum(not(cumSum(∟KEYS=K)))→I
://I is used later on in the code. It isn't pertaining to the problem.

I have done some testing with pause on this already, and I found the problem was in the if statement. It returns an 'INVALID DIM' error.

Anybody know what's wrong?


Solution

  • In this part (edited a bit)

    Repeat K=105
        getKey->K
        If max(|LKEYS=K
            prgmFINDIND
        Str1+sub(Str7,I,1->Str1
    End
    

    prgmFINDIND is only called if the key that was pressed is in the list, otherwise the index I is not changed (and possibly implicitly zero, or whatever other value that was left there).

    Pressing GOTO on the INVALID DIM actually goes to Str1+sub(Str7,I,1->Str1, indicating that a bad index was used to index into Str7.

    It could be fixed by using an If/Then block, which can cover more than one statement:

    Repeat K=105
        getKey->K
        If max(|LKEYS=K
        Then
            prgmFINDIND
            Str1+sub(Str7,I,1)->Str1
        End
    End