ID:140755
 
Code:
    Say(t as text)
world << "[src]: [t]"
if(Sayset)
winset(src,"Input","text = Say \" ")


Problem description:
I'm trying to make the Input box have Say " as it's default value.

It 'should' in my opinion make the text in the "Input" control show ' Say " ' Yet it only outputs ' Say '. Is there a reason for this? If so what am I doing wrong?

The winset value you're looking for is <code>winset( src, "Input", "text=\"say \\\"\"" )</code>.

Also, if you want to set Your input text to ' say " ' by default, don't use winset(), instead take a look at <code>client.command_text</code> in the help file via pressing f1 in Dream Maker.
In response to Metamorphman
Metamorphman wrote:
The winset value you're looking for is <code>winset( src, "Input", "text=\"say \\\"\"" )</code>.

Also, if you want to set Your input text to ' say " ' by default, don't use winset(), instead take a look at <code>client.command_text</code> in the help file via pressing f1 in Dream Maker.

If you put ! in front of say it will have the same effect. This is actually the preferred method of setting default text in an input box; the client.command_text var is deprecated.

For simplicity I should point out that any time you're using winset() with text that includes quotes, or generally anything other than letters and numbers, your best bet is to use url_encode() to encode the text or else use list2params().

Lummox JR
In response to Lummox JR
Lummox JR wrote:
If you put ! in front of say it will have the same effect. This is actually the preferred method of setting default text in an input box; the client.command_text var is deprecated.

Damn those undocumented features! Now I look like a fool. :(
In response to Metamorphman
Metamorphman wrote:
Lummox JR wrote:
If you put ! in front of say it will have the same effect. This is actually the preferred method of setting default text in an input box; the client.command_text var is deprecated.

Damn those undocumented features! Now I look like a fool. :(

More so in that the ! feature is in fact documented.

Lummox JR
In response to Lummox JR
..:(

Now I'm going to kill myself searching for the documentation of this ! feature.

[EDIT] Wow, I found it. Now I'm going to curse Lummox, put a paper bag over my head, and strut outside.
You need to surround the value you're setting with (either single or double) quotes if it includes special characters, such as spaces and quotes, for them to be properly interpreted and accepted. In other words, it amounts to something like this:
var/newvalue = "the new parameter value here" 
winset(player,control,"param='[newvalue]'")

Note the single parentheses surrounding only the actual new parameter value in the string (using double quotes instead is also possible, but as those need to be escaped or used with a special syntax to be accepted, they're just less convenient).
There also shouldn't be spaces between the parameter name, the equal sign and the new value, similarly to HTML. So your winset() line done properly would look something like this:
winset(player,"input1","text='Say \"'")


Keep in mind however that, as others have mentioned, there is a built-in feature for default text/commands in input controls, so that to achieve behavior similar to what you've tried to do, you don't need to constantly re-set the command text on the input control after every time the player submits a command. If you set an input control's command parameter to a value beginning in an exclamation mark (!), the rest of the value will be set as the input's default command text, which reappears whenever the text is submit (but can still be cleared by the player).
There is also another option, which is to designate the "say" command as the actual default command of the input control, meaning everything typed in the control always goes as parameters to that command, so the player can't use other commands through that control. You can make a typical "chat box" out of an input control using this. It's done by setting the command parameter directly to the wanted default command (so no exclamation mark).
Note the command parameter can be edited directly through the interface editor in the input's properties, so if you want to use it then you don't have to do it with a manual, at-runtime winset().
In response to Kaioken
Kaioken wrote:
You need to surround the value you're setting with (either single or double) quotes if it includes special characters, such as spaces and quotes, for them to be properly interpreted and accepted. In other words, it amounts to something like this:
> var/newvalue = "the new parameter value here" 
> winset(player,control,"param='[newvalue]'")

Note the single parentheses surrounding only the actual new parameter value in the string (using double quotes instead is also possible, but as those need to be escaped or used with a special syntax to be accepted, they're just less convenient).
There also shouldn't be spaces between the parameter name, the equal sign and the new value, similarly to HTML. So your winset() line done properly would look something like this:
> winset(player,"input1","text='Say \"'")


It's worth pointing out that there is a distinction between double and single quotes in winset(). The distinction usually doesn't come into play much and shouldn't be an issue in setting input.command, but basically single quotes are for file names and double quotes are for text. Ideally this should use text. Also, the [newvalue] is safest when passed through url_encode() if it contains any questionable characters at all.

Lummox JR