Trying to display what position the matrix editor is at - ti-basic

I have a TI-84 Plus CE (although I kind of want it to be backwards compatible, and compatible with the nSPIRE and TI-84 Plus)
I am trying to output onto the screen what position the matrix editor is at, and I am getting an ERROR:syntax, although (to the best of my knowledge about this language) the statement is valid.
my code is:
:Input "NUM OF ROWS?",A
:Input "NUM OF COLUMNS?",B
:{A,B}->dim([A])
:For(R,1,A)
:For(C,1,B)
:Disp "LOCATION: ("R","C")"
:Input "VALUE?",E
:E->[A](C,D)
:End
:End
:ChiSquared-Test([A],[B])
side note: i'm also getting a "divide by zero error" on the chi-squared test, for an unknown reason.

Fixed The Problem!
FIX:
Disp "Matrix Location:",{R,C}
The Reason the error happened was because in TI Basic, the option to have variables displayed outside the text is not available, so you have to do a 2 line display with the description in the first line, and the matrix location in the next line.
(R,C) when in a Disp statement throw an error, so you need to use the curly brackets instead like so: {R,C}.

Related

if statements inside command

I am trying to make a if statement for a CLI i am making in batch. this is the code
if "%command%" == "browser"(
echo Warning, this will only change the default broswer for this session
echo What would you like the default browser to be changed to?
set /p browserdefault=
)
I want it to check "browserdefault" and see if it is chrome, edge or a diffrent broswer
if it is none of those it should say "error, invalid broswer."
is there any way for there to be a if statement inside of the already existing if statement? like if %browserdefault% is "chrome" start C:%username%\filepath\tochrome?
I tried many diffrent ways but none of them seems to work
As pointed out in the other answer this is Windows batch. I do not know a way of nested if statements.
I would use call statements to get rid of the nested if statements like this:
:getCommand
set /P command=Enter command:
call :%command%
goto :getCommand
:browser
set /P browserdefault=Enter browser:
if not "%browserdefault%"=="chrome" if not "%browserdefault%"=="edge" echo error, invalid broswer.
goto :eof
What you are trying to do is right, noble and good. However, this is Windows batch. The ordinary rules of style & good taste do not apply.
You should not try to nest other statements inside a batch command. There are times this will appear to work, but (based on a number of factors, such as a poorly considered logical condition, or even different input strings!) will occasionally cause the block to fail miserably. This will set you up for a world of painful debugging.
The suggestion in the comments to search for menu is a good one. This should lead you to code that will have (what looks like) many unnecessary & unrelated blocks, all sprinkled with horrible gotos. Just... it's fine. This is Windows batch. It will work, it will be reliable. Try not to think about the style too much.
There are some example menus in this excellent Q&A:
Menus in Batch File
(as noted in at least one answer there, when using the naive if ERRORLEVEL 1, this will actually check if the number is equal OR greater than which requires starting with a higher ERRORLEVEL and working down to IF ERRORLEVEL 0, with a GOTO jump for each check -- using a statement with a % variable such as if "1" == "%ERRORLEVEL%" or similar avoids this pitfall).

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?
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

How do I remove the 'Done' message after my program has executed?

I made a program that is similar to clearing RAM. However, it always leaves a "Done" message followed by a dotted line after being executed. In addition, if you scroll up, you can see that the program was executed. Is there a way to remove both of these things? If you can't hide the fact that a program was executed, could you suppress the 'Done' message?
I have tried adding ClearHome" and " as the last line of my program, and neither stops the Done message from displaying.
Bonus points if your solution can be contained within the original program.
In a separate program, type the following line of code:
AsmPrgmFDCB00AEC9
Then at the end of the original program, type the following line of code:
Asm(prgmPROGRAMNAME
It is recommended that you test this out first with all programs archived, just running the above line of code alone, in case it fails. Hex codes like that one have been known to fail, and sometimes clears the RAM.
You can also try these other hex codes, but always keep in mind the warning above. My RAM has been cleared by this before, so use caution:
http://tibasicdev.wikidot.com/hexcodes
This works on TI 83 and 84, may be different with other calculator types.
EDIT:
I found a way to do this without an external program, and is much simpler.
Just add the following line of code to the end of your program:
Output(1,1," //no space, just a quote
You may or may not have to add ClrHome before that line of code.
This should prevent the Done message from appearing at the end.
Hope this helps!
Put an empty string at the end of your program, so your last line looks like this:
""
Or this
"
The empty string is stored to ans and will be displayed as a blank line rather than the Done message.
There is also an assembly hexcode to do this without leaving the blank line at the top:
FDCB00AEC9
When run at the end of the program using one of the various methods of running assembly, it will leave you with a blank, fully operational homescreen.
Outputting an empty string will prevent the Done message and also preserve Ans, in case a calling program is expecting to use it.
Output(Y,X,"")
See http://tibasicdev.wikidot.com/output for more details on Output(.
In your situation, run Clear Entries (found under Mem), then scroll up so that the Done message is selected and press Clear to get rid of it.

Fortran77 User Input Validation

I need the user to enter only real numbers when prompted. An error message should be displayed and program should stop in case the user enters a character or any other symbol. How can i do this in fortran 77.
I assumed, you probably want to have more tries, because what you have in your question does the compiler does automatically.
You can use the IOSTAT= or ERR= specifiers.
INTEGER IE
DO I = 1, MAX
READ(*,*,IOSTAT=IE) X
IF (IE.eq.0) GOTO 10
PRINT *,"Wrong input, try again."
END DO
10 CONTINUE
or
GOTO 10
20 PRINT *,"Wrong input, try again."
10 READ(*,*,ERR=20) X
improving the user interface a little, i like to read a string, then do the error check on an internal read:
character insting*80
ie=1
do while(ie.ne.0)
read(*,'(a)')instring
if(instring(1:1).eq.'q')stop
read(instring,*,iostat=ie)x
if(ie.ne.0)then
write(*,*)'invalid input ',trim(instring),' is not a real number'
endif
enddo
(note trim is not f77 btw, but its easy enough to replicate if needed)
Note, with some effort you can handle the pathalogic cases. A leading '/' or ',' throws no error but leaves the value of x unchanged (likely system/compiler dependent however!), so you can do something like this:
x=-999999.
read(instring,*,iostat=ie)x
if(ie.eq.0.and.x.eq.-999999.)then
.. code to handle error..
endif
You could alternately use index to look for the bad characters. On my system a decimal . by itself is taken as zero. That gets a bit cumbersome to handle, but it can be done by parsing instring

Xcode Using Exponents

This is probably a simple question, but I a variable "side" to be divided by the square of the variable "curNum". Currently, my code for this looks like
side = inputNum/(curNum^2);
However, this gives me the error "Invalid operands to binary ^" How can I successfully use exponents?
Try
pow(curNum, 2)
Should work......

Resources