Nice Input() trick to show blank entry for values

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
aliasmask
Deity
Posts: 8609
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Nice Input() trick to show blank entry for values

Post by aliasmask »

Usually, when you leave a value blank for input it puts that annoying 0 in it's place. Here's one way to avoid that:

Code: Select all

[H: hasInput = input("Enter Table Name|tableName=||PROPS|SPAN=TRUE SETVARS=UNSUFFIXED")]
Attachments
example.jpg
example.jpg (15.69 KiB) Viewed 601 times

User avatar
wolph42
Deity
Posts: 9790
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Nice Input() trick to show blank entry for values

Post by wolph42 »

thnx!

Isn't there (or maybe I should say shouldn't there be) a 'MT tips an tricks' spot on this forum where we can put these little tricks posts in?
I know I have posted a couple of nifty tricks like my 'auto-populate-token-with-macros' trick and I've seen numerous other that gradually get lost in the pit forum chaos. Only to be found if you know exactly what your looking for, though in most cases the tricks you will never look for them...

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: Nice Input() trick to show blank entry for values

Post by biodude »

aliasmask wrote:Usually, when you leave a value blank for input it puts that annoying 0 in it's place. Here's one way to avoid that:

Sweet! That's always been a HUGE annoyance.
The only limitation, I suppose is that the variable name is visible as the prompt (and the variable name/contents must be StrProp-compatible).
:shrug: oh, well.
Still, Very clever :mrgreen:
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: Nice Input() trick to show blank entry for values

Post by JML »

biodude wrote:The only limitation, I suppose is that the variable name is visible as the prompt (and the variable name/contents must be StrProp-compatible).

I had a similar problem with an input() I did to change token states. Having state names with blank inside quickly became an obvious problem at some point :roll: What I did was replacing blank characters with underscores in the states names, which I was able to replace() to get back the blank for a decent label. The replacement might not be possible in this case, but the underscore make for a quite readable trade-off.

Nice trick anyway. Thank you.

prestidigitator
Dragon
Posts: 317
Joined: Fri Apr 23, 2010 8:17 pm

Re: Nice Input() trick to show blank entry for values

Post by prestidigitator »

Maybe make a note of it on the wiki page for [wfunc]input[/wfunc].
"He knows not how to know who knows not also how to un-know." --Sir Richard Burton

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Nice Input() trick to show blank entry for values

Post by CoveredInFish »

prestidigitator wrote:Maybe make a note of it on the wiki page for [wfunc]input[/wfunc].

Done.

User avatar
aliasmask
Deity
Posts: 8609
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Nice Input() trick to show blank entry for values

Post by aliasmask »

Thanks. I was too lazy to do it myself.

Post Reply

Return to “Macros”