Page 1 of 1

Checking caps in INPUT macro

Posted: Mar 8th, ’18, 23:48
by orlando2bjr
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).

Re: Checking caps in INPUT macro

Posted: Mar 9th, ’18, 20:21
by Marko
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%

Re: Checking caps in INPUT macro

Posted: Mar 10th, ’18, 09:37
by orlando2bjr
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.

Re: Checking caps in INPUT macro

Posted: Mar 10th, ’18, 10:45
by Marko
You are welcome! :D