suggestion on using %INPUT_name% once but getting 2 different-formatted outputs?

Discussion, questions and support.
Post Reply
RMDoubleYou
Posts: 11
Joined: Sep 21st, ’17, 21:19

Post by RMDoubleYou » Apr 11th, ’19, 10:53

Hello.

I'm currently in a java software development traineeship and now quite often i need to write a 'getter' and a 'setter'.
The IDE (IntelliJ) can do this automatically but if its not necessary i'd rather not get the mouse and do some clicks (yeah i am very lazy -_-).
My idea was to have a text expander with the following content:

Code: Select all

public %INPUT_type% get%INPUT_name%{(}{)} {{}
return this.%INPUT_name%{;}
Now lets say for %INPUT_name%, i enter "counter" than the output will be

Code: Select all

public int getcounter() {
   return this.counter;
}
(IntelliJ adds the 'tab' and the closing bracket very nicely)

But i want to have Fastkeys type the following

Code: Select all

public int getCounter() {     --> notice the capital letter C here, that's the difference
    return this.counter;                   --> but no capital letter C here. I've been taught that this is convention and i'd like to follow this convention.
}
Now i could get the following convention by asking for the name twice (%INPUT_name1% and %INPUT_name2%) but this can typo's.
Is it possible to only have one %INPUT_name%, but tell Fastkeys to type it once WITH a capital letter and once WITHOUT a capital letter?

Thanks for your help in advance,
With kind regards,
-RMDoubleYou
User avatar
Tom
Posts: 268
Joined: Nov 24th, ’15, 23:39

Post by Tom » Apr 11th, ’19, 11:23

One way to handle this is by using a small script in Insert Command Code macro:

Command (Type: Send)

Code: Select all

%INPUT__Type%%INPUT__Name%%CODE_script%
CODE_script:

Code: Select all

Send, public %INPUT__type% get%INPUT__name%{(}{)} {{}
StringUpper, INPUT__name, INPUT__name, T
Send, {Enter}return this.%INPUT__name%{;}
Note that I used 'No Output' prefix "_" in front of a variable name to instruct FastKeys not to output the value.
RMDoubleYou
Posts: 11
Joined: Sep 21st, ’17, 21:19

Post by RMDoubleYou » Apr 12th, ’19, 09:15

Hello Tom,

Thanks for the answer, It seems to be doing what i want.
except for where the capital letter is printed is precisely reversed.

When i now 'call' this text expansion as you have described it i get the following:

A popup with:
"_type" ---> boolean (what i enter)
"_name" ---> taken

(so far so good)
and output is

Code: Select all

public boolean gettaken() {
return this.Taken;		---> where i GET the capital letter now


But i would like:

Code: Select all

public boolean getTaken() {	---> where i WANT the capital letter. 
return this.taken;


I'll play around a bit and see if i can get it myself,
But i'd be gratefull if you could help me again.

With kind regards,
RMDoubleYou
RMDoubleYou
Posts: 11
Joined: Sep 21st, ’17, 21:19

Post by RMDoubleYou » Apr 12th, ’19, 09:26

Hello again,

I managed to get it to work as how i want it by changing the Command Macro to the following:

Code: Select all

StringUpper, INPUT__nameUpper, INPUT__name, T
Send, public %INPUT__type% get%INPUT__nameUpper%{(}{)} {{}
Send, {Enter}return this.%INPUT__name%{;}
Thanks again for the help! :D
RMDoubleYou
Post Reply