ID:168554
Sep 27 2005, 6:06 pm
|
|
Very shortly and simply put, how would you make it to where, in a text input, someone couldn't just go " " and enter that as a message to avoid an if(!msg) check?
|
In response to Lummox JR
|
|
Seeing as I have no clue how that functions(Not farmiliar with copytext(), text2ascii(), or length()), I'm assuming you want me to use it as trim(msg) upon showing a message via a verb(trim() remaining untouched), however that gives me a lovely runtime error.
<font color=darkred face=System>runtime error: type mismatch proc name: trim (/proc/trim) usr: Sinoflife (/mob) src: null call stack: trim(" ") Sinoflife (/mob): say(" ")</font> |
In response to Sinoflife
|
|
Minor typo on my part. if(s>1) should have been if(i>1) instead.
Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Minor typo on my part. if(s>1) should have been if(i>1) instead. Thanks, but one problem still remains, it's still possible to enter a message in with one space, which was the main thing I wanted to prevent. |
In response to Sinoflife
|
|
You can use if(!ckey(msg)) which will be false unless there are numbers or letters within msg.
|
In response to Nick231
|
|
Ah, thanks. Got what I was asking for and a nice proc to trim "whitespace".
|
In response to Sinoflife
|
|
Sinoflife wrote:
Thanks, but one problem still remains, it's still possible to enter a message in with one space, which was the main thing I wanted to prevent. If you're testing the result of trim() correctly, then you shouldn't be having that problem. How are you using the proc? Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Sinoflife wrote: ID: 395833. Using it in communication verbs. |
In response to Sinoflife
|
|
Sinoflife wrote:
ID: 395833. Using it in communication verbs. Uh, why did you link back to my post? I asked how you're using the proc, meaning: How did you actually use it in your code? Lummox JR |
In response to Lummox JR
|
|
From what I see, that link brought me to my post. But I'm using it like this, as an example:
verb/say(msg as text) |
In response to Sinoflife
|
|
Sinoflife wrote:
From what I see, that link brought me to my post. But I'm using it like this, as an example: verb/say(msg as text) Then you're not using it correctly. You can't tell if msg is just empty space if you're not actually asking that. Nowhere in that code are you checking the result and bailing out if need be. This is what it should look like: verb/say(msg as text) Lummox JR |
You can trim the string down to eliminate whitespace like that.
That will return an empty string if a user types in just a space, so you can run a string through trim() first before checking it.
Lummox JR