Page 1 of 1

Nice Input() trick to show blank entry for values

Posted: Wed Jun 30, 2010 2:02 am
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")]

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

Posted: Wed Jun 30, 2010 2:44 am
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...

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

Posted: Wed Jun 30, 2010 9:01 am
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:

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

Posted: Wed Jun 30, 2010 12:01 pm
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.

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

Posted: Wed Jun 30, 2010 1:21 pm
by prestidigitator
Maybe make a note of it on the wiki page for Wiki: input().

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

Posted: Wed Jun 30, 2010 5:25 pm
by CoveredInFish
prestidigitator wrote:Maybe make a note of it on the wiki page for Wiki: input().
Done.

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

Posted: Wed Jun 30, 2010 5:34 pm
by aliasmask
Thanks. I was too lazy to do it myself.