Retrieve SubString Auto Hot Key - parsing

I have a list of strings I am trying to loop through within AutoHotkey, but within each loop I need to split each value into separate button presses:
List := ["1111","1222","1498"]
for key, value in List
Send, SubStr(val,1,1)
Send, SubStr(val,2,1)
Send, SubStr(val,3,1)
Send, SubStr(val,4,1)
The send isn't working and I suspect it is because my Send, SubStr code isn't written correctly. I would appreciate any advice/expertise thank you :)

I haven't tested this, but I'm guessing it might be because of legacy syntax. You should use expressions instead.
List := ["1111","1222","1498"]
for key, val in List
Send % SubStr(val,1,1)
Send % SubStr(val,2,1)
Send % SubStr(val,3,1)
Send % SubStr(val,4,1)

check for loop parse csv in autohotkey help

Related

How do you define the length of a parameter in ESC/POS?

I need to be able to print Hebrew characters on my Epson TM-T20ii. I am trying to get my printer to switch to character code page 36(PC862) using
ESC t36
for some reason the printer is switching to code page 3 and then printing the number 6.
Is there a way to let the printer know that the 6 is part of my command?
If you know of a different workaround please comment below.
Thanks
You are making a mistake, you aren't meant to replace n with an actual number.
The proper syntax in your case would be ←t$
Explanation: the manual says "ESC t n", n referring to the page sheet, however you don't replace n with a number rather with the ASCII character n, so in your example 36 = $ because $ is the 36th character on the ASCII table.

Parsing FETCH multiple UID

I need to write an IMAP code to parse the result of this command:
tag FETCH 1,2,3,4 ALL
Most of the time, the response is something like this
* 1 FETCH (FLAGS ... ) ENVELOPE ("time" "subject" ... )\r\n
* 2 FETCH (FLAGS ... ) ENVELOPE ("time" "subject" ... )\r\n
....
tag OK FETCH COMPLETE
And so on where each Envelope starts with asterik UID, and end with a CRLF, so I can use the CRLF as a parse point.
The problem is some servers are responding to me using IMAP string literals, ie {150}\r\n .... and since the \r\n is part of the string literal I can no longer use it as a parse point.
One idea is to use the * UID as a parsepoint, but if someone coincidentally uses that as an email subject, or whatnot, it will break the algo so I believe its a bad idea to do that.
Can someone tell me how to effectively parse this type of response without using CRLF? Most thanks you very much.
edit - Hopefully to improve question, I am trying to parse each individual ENVELOPE into it's own string based on parse points, where I need a parsepoint that identifies the start of one string and the end of another.
The trick you need is one to distinguish the two kinds of line feeds, and it exists: Start reading, read until you see a CRLF, then look at the start of what you have. Is it tag space OK, NO, BAD or PREAUTH? If so, you have a complete response. If not, look at the last 10-15 characters. Are they "{", a number, optionally a plus sign, and "}" and the CRLF? If so, read until the next CRLF and repeat. If not, you have a complete response.
Note that in IMAP, you have to act on a response before you can parse the next one. MSN handling breaks if you don't, there may be other problems too.

Setting the length for when ~P wrapps the text in erlang

Is there a way to make erlang print the full string even if one has used ~P in a io:format function?
Im having some troubles with EDoc and it keeps wrapping the error messages to ....
Is there any flags or other way to force erlang to print the entire string?
The only method I have found is to use io_lib:print(Term, Column, LineLength, Depth). That function allows you to specify the starting column, the line length to control wrapping, etc. It returns a string which you can then print using io:format with ~s format.

Formatting a string in delphi

I want to update a text like "Updating report (1 0f 5)". I thought format function will help me to do that. I want something like this
string := Format('Updating report ( %d of %d, [1], [2])', loop, count );
but it is not possible. I have an option to have loop and count stored in a string and concatenate everything. But is there any other way to achieve what i want?
Your syntax is wrong. The second parameter to the Format is an open array containing the arguments. So you need to wrap your list of arguments in what is known as an open array constructor.
An open array constructor is a sequence of expressions separated by commas and enclosed in brackets.
So, write the code like this:
str := Format('Updating report (%d of %d)', [loop, count]);

How to write an array into a text file in maxima?

I am relatively new to maxima. I want to know how to write an array into a text file using maxima.
I know it's late in the game for the original post, but I'll leave this here in case someone finds it in a search.
Let A be a Lisp array, Maxima array, matrix, list, or nested list. Then:
write_data (A, "some_file.data");
Let S be an ouput stream (created by openw or opena). Then:
write_data (A, S);
Entering ?? numericalio at the input prompt, or ?? write_ or ?? read_, will show some info about this function and related ones.
I've never used maxima (or even heard of it), but a little Google searching out of curiousity turned up this: http://arachnoid.com/maxima/files_functions.html
From what I can gather, you should be able to do something like this:
stringout("my_new_file.txt",values);
It says the second parameter to the stringout function can be one or more of these:
input: all user entries since the beginning of the session.
values: all user variable and array assignments.
functions: all user-defined functions (including functions defined within any loaded packages).
all: all of the above. Such a list is normally useful only for editing and extraction of useful sections.
So by passing values it should save your array assignments to file.
A bit more necroposting, as google leads here, but I haven't found it useful enough. I've needed to export it as following:
-0.8000,-0.8000,-0.2422,-0.242
-0.7942,-0.7942,-0.2387,-0.239
-0.7776,-0.7776,-0.2285,-0.228
-0.7514,-0.7514,-0.2124,-0.212
-0.7168,-0.7168,-0.1912,-0.191
-0.6750,-0.6750,-0.1655,-0.166
-0.6272,-0.6272,-0.1362,-0.136
-0.5746,-0.5746,-0.1039,-0.104
So I've found how to do this with printf:
with_stdout(filename, for i:1 thru length(z_points) do
printf (true,"~,4f,~,4f,~,4f,~,3f~%",bot_points[i],bot_points[i],top_points[i],top_points[i]));
A bit cleaner variation on the #ProdoElmit's answer:
list : [1,2,3,4,5]$
with_stdout("file.txt", apply(print, list))$
/* 1 2 3 4 5 is then what appears in file.txt */
Here the trick with apply is needed as you probably don't want to have square brackets in your output, as is produced by print(list).
For a matrix to be printed out, I would have done the following:
m : matrix([1,2],[3,4])$
with_stdout("file.txt", for row in args(m) do apply(print, row))$
/* 1 2
3 4
is what you then have in file.txt */
Note that in my solution the values are separated with spaces and the format of your values is fixed to that provided by print. Another caveat is that there is a limit on the number of function parameters: for example, for me (GCL 2.6.12) my method does not work if length(list) > 64.

Resources