1

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?

Treyara
  • 47
  • 1
  • 7
  • It works on my calculator (btw you can use `If max(not(∟KEYS-K` to test if the key is in the list), might there be some relevant code in the omitted part? – harold Oct 22 '19 at 22:05
  • The stuff in the omitted part just gets the index K in ∟KEYS (hence the name ‘FINDIND’ (find index)). It stores it to ‘I’ and it does nothing but that. I don’t really think it affects it. I’m gonna try using your code though. – Treyara Oct 22 '19 at 22:21
  • Hopefully non-destructively, anything that deletes ∟KEYS or sets its length to zero would be an issue. On the one hand I don't expect that code to delete the list, but on the other hand that you're getting the error suggests that the list has been deleted – harold Oct 22 '19 at 22:23
  • I kinda thought that something like that was happening. Because of that, I went back to the home screen and displayed the list. ∟KEYS still showed the {41,42...} – Treyara Oct 22 '19 at 22:26
  • That's really mysterious, if the list exists when the condition is evaluated it should just work. Also I just thought of `If max(∟KEYS=K`, and for the index maybe `max(seq(X,X,1,dim(∟KEYS))*(∟KEYS=K` – harold Oct 22 '19 at 22:30
  • I'm going to try to use your second method of the 'number finder' and see if it works. I'll keep updated – Treyara Oct 22 '19 at 22:32
  • I am still getting the error – Treyara Oct 22 '19 at 22:40
  • Could you put the whole thing on [sourcecoder](https://www.cemetech.net/sc/) so I can run it too? There are some small syntax differences so keep that mind, just copy/pasting the code above won't work right – harold Oct 22 '19 at 22:41
  • That's also a nice prgmFINDIND, that should be OK – harold Oct 22 '19 at 22:50
  • This is the code. This is actually for a hangman game I have and it is for players to enter a 'password' so other people can't play for them. http://sc.cemetech.net/?hash=6USUhUTvrRrGN3O4GyI1xSf6ZDbr – Treyara Oct 22 '19 at 22:53
  • Well, there is something else. If you substring the Str7 variable with `I`, it may not work, because the part after the `prgmFINDIND` is not inside the `If` so it always runs, also when no key/bad key is pressed and then `I` might be bad. – harold Oct 22 '19 at 22:57
  • what do you mean by that. How does it always run? – Treyara Oct 22 '19 at 22:59

1 Answers1

1

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
harold
  • 61,398
  • 6
  • 86
  • 164
  • Sorry for being a novice, but what is the difference between an if statement and an if then statement? – Treyara Oct 22 '19 at 23:08
  • @yeeboi an [`If` command](http://tibasicdev.wikidot.com/controlflow#toc1) only affects the next command, an `If/Then` can contain many commands until it is closed by a corresponding `End` (or semi-closed with an `Else`, or closed implicitly by the end of the program.. there are various details) – harold Oct 22 '19 at 23:10
  • oh ok. Thank you. I express my gratitude, I just meant an if then in the place on my if then – Treyara Oct 22 '19 at 23:15