Checking caps in INPUT macro

Discussion, questions and support.
Post Reply
orlando2bjr
Posts: 27
Joined: Oct 3rd, ’17, 12:26

Post by orlando2bjr » Mar 8th, ’18, 23:48

Hi again,

New problem:
I want to use input, but check if the first letter is capital or not and use the appropriate tag.

Ex:

$T%INPUT_test%:%INPUT_test2%; ; if first letters are lowercase
$t%INPUT_test%:%INPUT_test2%; ; if first letters are uppercase

I tried using Insert Command Code, but I can't get the values of INPUT_test and INPUT_test2 to test for case.
If possible, I'd like to keep using macros so it's easy to explain to coleagues how to tweak this to their needs (non programmers).
orlando2bjr
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Mar 9th, ’18, 20:21

You can use Insert Command Code macro. Example:

Substitute (note that the name of Input field is "_test". "_" is added to prevent sending this value):

Code: Select all

%INPUT__test%
%CODE_TestUpper%
The content of TestUpper Command Code macro:

Code: Select all

first:=SubStr(INPUT__test,1,1)
if first is upper
	Send, This is UPPER: %INPUT__Test%
else
	Send, This is LOWER: %INPUT__Test%
orlando2bjr
Posts: 27
Joined: Oct 3rd, ’17, 12:26

Post by orlando2bjr » Mar 10th, ’18, 09:37

Worked perfectly and it's easy to explain how to tweak.
Look at the final version (except variable names):


Main Send code, without line breaks and 2 variables:

Code: Select all

%INPUT__test%%INPUT__test2%%CODE_TestUpper%
Command:

Code: Select all

first:=SubStr(INPUT__test,1,1)
if first is upper
	Send, $u%INPUT__Test%:%INPUT__Test2%;
else
	Send, $U%INPUT__Test%:%INPUT__Test2%;
I can't thank you enough!!!
A few more tests and I'll begin recommending fastkeys to all my fellow translators.
orlando2bjr
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Mar 10th, ’18, 10:45

You are welcome! :D
Post Reply