I've read the documentation for Auto Hot Key, but am new to writing scripts. I keep getting errors.
I want a very simple script - so when I use a hotkey CTRL-ALT-N - Autohotkey creates a random number that is:
3 Digits - Decimal - 8 Digits
With the very first digit of the first group being between 1 and 4.
The rest can be completely random.
Off the sample scripts I tried to edit one posted - but I am doing something wrong. If anyone could help it would be really appreciated!
The output should look like this: 314.99382028 The first number always between 1 and 4, the rest random, and decimal always the 4th character.
Then, it should just paste the number to where ever you currently are within windows - not pop up display.
Thanks for anyone who could take a quick look and help out.
Rocket
^!n:: ;<-- change this if you want a diff hotkey
Chars1 = 1234
Chars2 = 1234567890
Chars3 = .
str =
clipboard =
UpperRange = 3 ;<-- use all 3 character strings
len = 12 ;<-- number of characters in the number
; generate a new number
loop, %len%
{ random,x,1,%UpperRange% ;<-- selects the Character string
random,y,1,26 ;<-- selects the character in the string
if (x = 12) ; if numeric there are only 10 digits
}
{ random,y,1,10
StringMid,z,Chars%x%,1 ;<-- grab the selected letter
str = %str%%z% ;<-- and add it to the number string
}
clipboard = %str% ;<-- put the completed string on the clipboard
Clipwait ;<-- wait for the clipboard to accept the string`
AND THEN PASTE WHERE EVER MY CURSOR IS - Not sure how to do that.
Thanks so much for the help!
Rocket
This should do the job if I understood it correctly:
^!n::
SendInput, % "{LButton}" . RandomString(1,"1234") . RandomString(2) . "." . RandomString(8)
Return
RandomString(length,chars:="0123456789") {
charsCount := StrLen(chars)
Loop % length {
Random, num, 1, % StrLen(chars)
string .= SubStr(chars,num,1)
}
Return string
}
Since you have your answer on your clipboard, you could simply use:
Send, ^v
This will paste where your caret is, not your mouse cursor, so if you want to paste where your mouse cursor is, just add Click before....
Click
Sleep, 30
Send, ^v
Related
I have some code
::redo::
io.write("input: ")
var = io.read("*n")
if var then
if var > 5 and var < 10 then io.write("yes\n") goto redo
else io.write("invalid\n") goto redo end
else io.write("invalid\n") goto redo end
that is supposed to check a numeric input value and return if it's within a certain range. If it isn't a numeric value, it's supposed to "redo" the script and ask for input again. The issue is that whenever it takes an input that isn't a number it repeats io.write("input: ") and io.write("invalid\n") unceasingly meaning it's skipping the var = io.read("*n") line. Is there a special meaning or quirk to io.read("*n") that keeps it from reevaluating? The code seems to work if replaced with io.read()
When you call io.read('*n') and it doesn't find a number, it doesn't use up the input, and any calls to io.read('*n') will read the same input over and over. You need to eat up the input and discard it by calling io.read('*l'). That will let you read new input with io.read('*n').
Another method would be to read a line with io.read('*l'), extract a number from it with string.match and convert it to a number with tonumber. Then you don't have to read the same input twice, but you'd have to decide what types of number notation you want to match. (io.read('*n') accepts various types of numbers, including hexadecimal and scientific notation.)
I have an order number which is character 10 positions.
I would like to know where the leading blanks end. Only blanks.
So if the number is
' 012345' I want 012345 - Can I do this in RPG? I have tried some FREE codes
but have trouble getting to work in general. So I prefer the old way
or Free is ok if we must.
So what i need to know is, how many positions of the 10 position field are having data? so if the data is 012345 this means 6 positions are filled and 4 are blanks.
Use %scan to locate the blank.
dcl-s source char(10) inz('12345');
dcl-s pos zoned(5);
pos = %scan(' ':source) - 1;
*inlr = *on;
After the eval pos = 5.
If you want to deal with the value without leading blanks, you can use %trim or %trimL. The former will trim spaces from the front and end. The latter will only trim spaces from the front (left).
newOrder = %trimL( originalOrder );
Although your example is a bit odd. Either you typo'd what you want (two 3's?) or if you really do want to insert a 3, then that would require more work. Let me know.
Edit: Maybe this logic better answers what you're looking to do.
To count the number of non-blanks, you can do this:
valueCount = %len( %trim( originalOrder ) );
And if you need to know the number of blanks instead, it's simply:
blankCount = %len( originalOrder ) - %len( %trim( originalOrder ) );
I hope that answers your question.
You can use XLATE to replace all blanks in your string with zeros
The text is a string with undefined number of words. The alignment should be something like this:
The text is starting from here
then when the line is over it
goes to the next line etc.
Is it possible to align text this way in Unity using UI components?
No, there's no way built-in.
Note that Unity DOES NOT offer "text length" functions - as for example iOS does.
I really cannot think of anyway at all to find out "where it wraps" a line. You could, perhaps, iterate over each character one by one growing the string one character at a time, and when the width stops increasing, you know, it has wrapped. (Get the width with .renderer.bounds.size.x )
I would probably encourage you to just have say three UI.Text and separate your string. Simply, separate the string in to say chunks of 50 characters (stopping at a space) or perhaps seven words. (They won't be exactly the same length, but it will be fine.)
NOTE
If you're a new Unity programmer or hobbyist, the usual solution to things like this is to
"USE AN ASSET!"
Someone somewhere has probably programmed what you need. So start googling for something like "free asset, wrap text around a shape" or similar. Often, it pays to email the people who make such packages, and they often know something that does what you need, if their one does not.
Example .. http://forum.unity3d.com/threads/text-box.124906/
I easily found that by googling unity3d text utility wrap around a shape
Here's some code to split a LONG line of reasonable text, in to a number of lines of length limit say 50 characters. Note that the text must be "reasonable", you can't have any ridiculously long words etc.
string wholeSentence = "Your whole sentence here ... goes on and on.";
List<string> words = new List<string>(
wholeSentence
.Split(new string[] { " " },
StringSplitOptions.RemoveEmptyEntries)
);
List<string> finalLines = new List<string>();
int count = 0;
string nextLine = "";
foreach (word w in words)
{
nextLine = nextLine + w + " ";
count += w.Length;
if (count>50)
{
finalLines.Add(nextLine);
count=0;
nextLine = "";
}
}
if (nextLine!="") finalLine.Add(nextLine);
that will give you all the lines, in the List "finalLines" ! Cheers
I am wondering how to make something where if X=5 and Y=2, then have it output something like
Hello 2 World 5.
In Java I would do
String a = "Hello " + Y + " World " + X;
System.out.println(a);
So how would I do that in TI-BASIC?
You have two issues to work out, concatenating strings and converting integers to a string representation.
String concatenation is very straightforward and utilizes the + operator. In your example:
"Hello " + "World"
Will yield the string "Hello World'.
Converting numbers to strings is not as easy in TI-BASIC, but a method for doing so compatible with the TI-83+/84+ series is available here. The following code and explanation are quoted from the linked page:
:"?
:For(X,1,1+log(N
:sub("0123456789",ipart(10fpart(N10^(-X)))+1,1)+Ans
:End
:sub(Ans,1,length(Ans)-1?Str1
With our number stored in N, we loop through each digit of N and store
the numeric character to our string that is at the matching position
in our substring. You access the individual digit in the number by
using iPart(10fPart(A/10^(X, and then locate where it is in the string
"0123456789". The reason you need to add 1 is so that it works with
the 0 digit.
In order to construct a string with all of the digits of the number, we first create a dummy string. This is what the "? is used
for. Each time through the For( loop, we concatenate the string from
before (which is still stored in the Ans variable) to the next numeric
character that is found in N. Using Ans allows us to not have to use
another string variable, since Ans can act like a string and it gets
updated accordingly, and Ans is also faster than a string variable.
By the time we are done with the For( loop, all of our numeric characters are put together in Ans. However, because we stored a dummy
character to the string initially, we now need to remove it, which we
do by getting the substring from the first character to the second to
last character of the string. Finally, we store the string to a more
permanent variable (in this case, Str1) for future use.
Once converted to a string, you can simply use the + operator to concatenate your string literals with the converted number strings.
You should also take a look at a similar Stack Overflow question which addresses a similar issue.
For this issue you can use the toString( function which was introduced in version 5.2.0. This function translates a number to a string which you can use to display numbers and strings together easily. It would end up like this:
Disp "Hello "+toString(Y)+" World "+toString(X)
If you know the length of "Hello" and "World," then you can simply use Output() because Disp creates a new line after every statement.
I have MATLAB set to record three webcams at the same time. I want to capture and save each feed to a file and automatically increment it the file name, it will be replaced by experiment_0001.avi, followed by experiment_0002.avi, etc.
My code looks like this at the moment
set(vid1,'LoggingMode','disk');
set(vid2,'LoggingMode','disk');
avi1 = VideoWriter('X:\ABC\Data Collection\Presentations\Correct\ExperimentA_002.AVI');
avi2 = VideoWriter('X:\ABC\Data Collection\Presentations\Correct\ExperimentB_002.AVI');
set(vid1,'DiskLogger',avi1);
set(vid2,'DiskLogger',avi2);
and I am incrementing the 002 each time.
Any thoughts on how to implement this efficiently?
Thanks.
dont forget matlab has some roots to C programming language. That means things like sprintf will work
so since you are printing out an integer value zero padded to 3 spaces you would need something like this sprintf('%03d',n) then % means there is a value to print that isn't text. 0 means zero pad on the left, 3 means pad to 3 digits, d means the number itself is an integer
just use sprintf in place of a string. the s means String print formatted. so it will output a string. here is an idea of what you might do
set(vid1,'LoggingMode','disk');
set(vid2,'LoggingMode','disk');
for (n=1:2:max_num_captures)
avi1 = VideoWriter(sprintf('X:\ABC\Data Collection\Presentations\Correct\ExperimentA_%03d.AVI',n));
avi2 = VideoWriter(sprintf('X:\ABC\Data Collection\Presentations\Correct\ExperimentB_002.AVI',n));
set(vid1,'DiskLogger',avi1);
set(vid2,'DiskLogger',avi2);
end