call "EOF" in Ti-83 BASIC - eof

Is there an EOF operator in Ti-83 Basic like in many other languages, such as C?
I know that some programmes terminate when the "On" button is pressed (much like the EOF operator, Ctrl+D, in *nix), but I haven't been able to figure out how this operation is assigned.
As a very bad example, say I have
:Prompt Str0
:While Str0 ≠ "EOF"
:Disp "This code works!"
:Prompt Str0
:End
I want it to print "This code works!" and then prompt for Str0 until I enter a key combo ("On" button, I'm guessing) that terminates the file.
Now of course there are other ways of expressing the code above that do not rely on EOF. I'm just trying to give a simple example of what a scenario in which EOF might be useful.

If you are looking for a way to get keypad input to end your program, there is no single function, but you can use getKey to write code to do it. Here is an example of how to make a program go until a certain key combination is entered, or the program is broken.
:Disp "This code works!"
:While getKey ≠ 21
:End
:While getKey ≠ 31
:End
:While getKey ≠ 45
:End
:Disp "Program ending"
:Stop
The above code displays "This code works!", then waits until 2nd, ALPHA, then CLEAR are pressed before displaying "Program ending" then quitting. If you are unfamiliar with the getKey function, I recommend this link. Good luck with your coding!

Related

AutoHotKey - LShift and RShift with arrow key, not working as I expected

>+Right::
Send % GetKeyState("LShift", "p") ? "+{End}" : "{End}"
return
code above is what I tried to implement (but failed).
However, code below, which was one of the tests, works... but not as smooth as I expected.
*Right::
If (GetKeyState("RShift", "p") && GetKeyState("LShift", "p"))
MsgBox Both Shift Keys
Else
MsgBox meh
return
It has some delay, and sometimes does not show me anything. This is so weird.
It could be manufacturer's problem, but I wanted to make sure. Any elegant solution to implement first code?
Seems that this simple thing is what you're looking for:
+<>+Right::End
>+Right::SendInput, {End}
It's using the simple remapping syntax and your shift key gets passed through because the remapping syntax internally uses {Blind}.
And the second hotkey doesn't use the remapping syntax, instead just a normal send command, so the shift key will be consumed.
Another option since the first one didn't work on OP's end for some reason?
>+Right::
+<>+Right::SendInput, % (InStr(A_ThisHotkey, "+<") ? "+" : "") "{End}"
Since you had the cool ternary in there as well, I put it in as well. That code is the same as this:
>+Right::SendInput, {End}
+<>+Right::SendInput, +{End}

Autohotkey Input Times Out Because MatchList Isn't Matched

Here's my AHK script
:*:if ::
SendInput IF{Space}
Input cond, I V T5,, then
msgbox %ErrorLevel%
msgbox %cond%
if (ErrorLevel = "Match")
{
SendInput {Enter}End If{Space}'%cond%
}
Return
When I type If x = 1 then I get an ErrorLevel of 'Timeout' and a cond of 'x = 1 then'
My understanding is that when I type then it's supposed to stop the Input and set the ErrorLevel to Match.
I've tried putting it in quotes, using single letters in the MatchList, and including and end key, but none of works. The few examples I could find of using MathList look just like mine.
Input cond, I V T5 *,,% " then"
Without the asterisk option, an item in MatchList needs to be the next thing typed. So If Then would match then in the MatchList. But If anything then doesn't match then in the MatchList because it's trying to match anything then, not just then.
With the asterisk option, if anything then is matched because the next thing typed after If contained then. That causes problems if you type if heathen then because the then in heathen triggers it. The space before then should fix that, but it doesn't.
AHK help says that the MatchList respects spaces, but it doesn't seem to do that when the space is before the first (or only) item in MatchList. The two ways around that are to include a dummy word at the beginning or to use the % thingy to quote the MathList item and include the space.
See also http://ahkscript.org/boards/viewtopic.php?f=5&t=3979
I strongly recommend using RegEx powered hotstrings for this purpose:
#Include <Hotstrings>
hotstrings("if (.*?) then", "If %$1% then``nEnd If%A_SPACE%")
The definition of "T" in the AutoHotkey Help File states this:
T: Timeout (e.g. T3). The number of seconds to wait before terminating the
Input and setting ErrorLevel to the word Timeout. If the Input times out,
OutputVar will be set to whatever text the user had time to enter.
Basically, this is saying exactly what is to be expected (and what is actually happening) with your script. So, for me when I type "if x = 1 then" my "if" is immediately replaced with the caps lock IF and a space.
After 5 seconds, the first MsgBox appears with "Timeout" as the text (again, expected since ErrorLevel is set to the word "Timeout" when the "T" option is present). Once that MsgBox is dismissed, I receive the second MsgBox which (according to the help file) contains OutputVar which is what I (the user) had time to enter in before the Timeout.

How to implement something like a select-case-esac structure in AutoHotKey

I am not sure how to start this one. I went through the help files of AHK with no result.
I need to establish a construct like this (this is not in either UNIX shell or in AHK scripting language. Just shows the idea I am after)
while true
do
gosub screenscrape
; here, all text on page is on clipboard
; variable "input" is a predefined portion of the clipboard
case $input in
string-1)
gosub subroutione1;;
string-2)
gosub subroutine2;;
...
*)
echo "not found"
sleep 1minute
done
to make the things more complex, the parts noted as string-1, through string-n are also variables, read in from few different files, depending on time of the day or by trigger from an event.
can someone point me to the right direction for this ?
Autohotkey does not have any case statements. What everyone does is to use if and else statements. (I know how it feels. I like case, too)
A few tips for you:
You can't have that $ or a - in your variable name in autohotkey
...but you CAN have an underscore.
You don't need to terminate your lines with a ;.
Here is a translation into autohotkey for you.
gosub screenscrape
; here, all text on page is on clipboard
; variable "input" is a predefined portion of the clipboard
if(string1){ ;if the variable is not blank it will evaluate to `true`
gosub subroutine1
}else if(string2){
gosub subroutine2
}else{
msgbox not found
sleep 60000 ;milliseconds
}
Also, you can use real functions in autohotkey - you don't have to rely on gosubs. If you use gosubs, make sure you place a return at the end of them. You should also read the autohotkey docs concerning the "auto execute" section.

Prevent completing-read from exiting with nil

I'm reading the documentation on completing-read, but I can't find a way to do what I need.
It says that:
(completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
. . .
REQUIRE-MATCH can take the following values:
- t means that the user is not allowed to exit unless the input is (or completes to) an element of COLLECTION or is null.
- nil means that the user can exit with any input.
- `confirm' means that the user can exit with any input, but she needs to confirm her choice if the input is not an element of COLLECTION.
- `confirm-after-completion' means that the user can exit with any input, but she needs to confirm her choice if she called
`minibuffer-complete' right before `minibuffer-complete-and-exit'
and the input is not an element of COLLECTION.
- anything else behaves like t except that typing RET does not exit if it does non-null completion.
What I need to do is something like:
(completing-read "What kind of project should I create? "
haxe-project-kinds
(lambda (x) (message "predicate: %s" x)) t)
This shouldn't return nil, because if it does, it's an error - but I don't want to run the user through all other options until she discovers that she got the very first one wrong.
More than that, the behaviour advertised in the documentation doesn't match what really happens. It makes absolutely no difference what I put in the 4'th argument's position, the behaviour is unchanged.
I'm not sure exactly which part of what you want is not satisfied by your sample code, so it's hard to give a good answer. My guess is that you want to prevent the user from hitting RET with an empty answer. Indeed completing-read does not prevent that, even with require-match set. The way this is usually handled is by using a non-nil value for the default argument, in which case this value is returned when the user just hits RET.
If that's not good enough, then you're probably going to have to use minibiffer-with-setup-hook and in the hook, setup a special keymap you've created for this purpose where RET is bound to a new function that signals an error if the minibuffer is empty and calls minibuffer-complete-and-exit otherwise.

Circumflex accent before c IN LISP

I'm studing lisp and I found this: (zoom in)^C ^C , but the text don't explain it, and I searched "^C ^C" in other places but didn't found anything. Can someone here help-me?
(I'm studying english yet, sorry if I wrote anything wrong)
"^C^C" is not AutoLisp; that would be for/is the macro language for menus and such.
Caret-C does "mean" CTRL-C.
What it does in the macro language:
^c means: cancel
^c^c means: cancel twice.
In AutoCAD we hit the ESC key (twice to cancel a command). The ^C^C is "good practice". -i.e. Before we issue or start a new command we cancel any current command.
The equivalent in AutoLisp would be:
(command) (command)
or
(repeat 2 (command))
I think they refer to the control-character ctrl-c you enter after entering (zoom in) in the REPL.
As others have said, most likely it means Ctrl+C, especially if you're using emacs, where two Ctrl+C presses (usually written "C-c C-c" in the emacs convention, though) means "run this using the default interpreter" in some language modes.
If I'm not mistaken, ^C usually represents the "Ctrl+C" modified keypress.
It won't work in a console on Windows, as Ctrl+C also means "break (execution)", but if you press Ctrl+V, Ctrl+P, etc., you'll see what I mean.