Using if string($1) to check for any input

For builders to discuss and ask building questions.
Post Reply
User avatar
Myn
Sword Apprentice
Sword Apprentice
Posts: 91
Joined: Mon Aug 04, 2003 3:23 pm
Location: Zhentil Keep
Contact:

Using if string($1) to check for any input

Post by Myn » Sat Jun 02, 2018 1:09 pm

Hello!
I was wondering if there is any way to have if string($1) == succeed if there is literally any text entered after it. I am looking for a way to return an error if only the intercept command that triggers this check is entered.

Thanks!

User avatar
Harroghty
Staff
Staff
Posts: 9259
Joined: Tue Jul 27, 2004 5:38 pm

Re: Using if string($1) to check for any input

Post by Harroghty » Sat Jun 02, 2018 5:53 pm

Can you describe your desired result a little more, please?
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons

User avatar
Myn
Sword Apprentice
Sword Apprentice
Posts: 91
Joined: Mon Aug 04, 2003 3:23 pm
Location: Zhentil Keep
Contact:

Re: Using if string($1) to check for any input

Post by Myn » Sun Jun 03, 2018 1:02 pm

Sure thing.
I have an intercept prog will echo in the room based upon what is entered after the intercept keyword. I would ideally like there to be a message echoedat the PC if they ONLY enter the intercept keyword, and no extra strings after the intercept keyword.

For example:

Code: Select all

>intercept_prog Keyword~
if string($1) == ""  [Like, a wildcard here would be awesome, just checking to see if anything is there for string $1]
  mpechoaround Whatever, it worked!
else
    mpechoat $n Hey ya gotta put something else there, you!
endif
~

User avatar
Harroghty
Staff
Staff
Posts: 9259
Joined: Tue Jul 27, 2004 5:38 pm

Re: Using if string($1) to check for any input

Post by Harroghty » Sun Jun 03, 2018 5:26 pm

I have never had an empty stringprefix($x) check. I have used empty commands before by allowing a PC to enter anything and then used $0 to reference and use the PC's input. In this case, you could look for a specific $1, or a specific set of $1s, but you would have to try a blank $1 and see what happens. Quotes would not be required, just a blank space for the RHS. I do know that blank intercepts do work (e.g. intercept_prog ~), so it's possible that this might work.
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons

Post Reply