[SOLVED] Prompt for Input

I'm a bit confused about this action.
When I add more lines to add more variables, what format should I use?
In here it shows regular names with capital letters, spaces, etc, even though it says it's a field for variables. Aren't variables supposed to have no spaces?
Are those names saved as local variables? Global variables? Does KM automatically remove all spaces?

So if I set mine to this:
image
Will it save as a variable? If so, will it be a global or local?
If it's local, will it automatically convert it to something specific?

EDIT: Ok so I was reading another page, and it seems that variables can have spaces.
That being said, does it mean that variables inside an Input Form will be saved as global automatically?

EDIT 2: So I noticed that it creates a global variable, which is not ideal. If I type "local_Full Name", when the prompt pops up it shows "_Full Name". Is this the right way to set a local variable there? I don't really care about how it looks, because it's just my personal workflow, but I'm curious if I'm missing something?

Local__My Variable will display as "My Variable".

3 Likes

So that's why people use the "double-underline" format that I find so annoying confusing! Thanks, @noisneil!

Every day's a school day on the KM Forum...

1 Like

Oh ok. I didn't know that. Good to know. Thanks for sharing.
I guess I will start using double underscores from now on, regardless of where I'm using it. Also, any special reason you use Local instead of local?
Now that we are digging these gems... haha

For real! Always learning...
Double underscore from now on

I saw someone else do it, adopted it and never thought about it again. I suppose I slightly prefer the way it looks but that's neither here nor there.

1 Like

Ok. I usually use small caps as the first letter and then use the camel case format.
Even though I'm not a developer myself, I remember getting that "tip" when I was playing around with JavaScript as people said it's a good practice.

Thanks for sharing!

This is quite handy. It's triggered by either a button on my Stream Deck or by the typed string, "%%%".

  • If I want to type Local__FilePath. I'll hit "%%%", then type "FilePath".

CleanShot 2022-11-04 at 20.15.32

  • If I've already typed "Filepath", I'll select it and hit the SD button.

CleanShot 2022-11-04 at 20.16.31

%Variable%%.kmmacros (56 KB)

Macro screenshot

1 Like

I use something similar to your first option, by using Mac's "Text Replacement" or Raycast's snippets.
I tend to use Text Replacement more often, because it syncs with my iPhone.
So usually my "snippets" start with $
For example, my email is assigned to $dwe (danny wyatt email)
I have a lot of those for emojis I use quite often as well for example $handsup will show :raised_hands:
I even have some assigned to longer sentences.

I will test your macro and see if I can use it myself.
Thanks for sharing!

1 Like

I was checking Raycast and the Snippets extension does this. I wasn't aware that we can add placeholders until today when I was checking it:

image

And you can even add the clipboard content:
image

1 Like

@noisneil,

Here it is in action:

Kapture 2022-11-05 at 08.27.34

1 Like

My version -- when I remember to use it!

I start typed string triggers with ;, and also use that as an end marker if the end isn't otherwise obvious. An optional v for if I want to include %Variable%, one of [gpiv] for scope, then the variable name, and finally ;.

So ;vgmyArray[1]; expands to %Variable%Global__myArray[1]%, ;ltheText; expands to %Local__theText%, etc.

KM Vars Expansion.kmmacros (5.5 KB)

Image

2 Likes

Crikey! I wouldn't trust my sausage fingers to get that right in one! :joy:

:slight_smile:

Obvs, you could do something like just automating the "wrapper" insertion then a ← to put the cursor in the right place ready for you to type the variable name -- your trigger would then be ;vg;, ;l;, and so on.

I find it easier to use one "command" with various arguments to do variations on a theme -- this expansion can be used whether you are in a text or calculation field, and for whatever scope you want -- rather than having different things for each. YMMV.

1 Like