Non-threaded

Forums » Feature Wishing Well » Read Thread

Suggestions for improvements and additions to the site.
This feature was rejected 12/11/2016: Going to reject this because adding duplicate functionality is a low priority, even though it might be more convenient.

Parsing variables in a text added by a script

9 years ago

Parse variable names in a text added by a script in the same way as it done in a normal text.

For example, %%SEX%=%0%he%%%%SEX%=%1%she%% in a normal text is replaced by "he" or "she". It is very useful.

But if you add a text trough a script, it is not replaced. You can achieve the same effect with IF/THEN/ELSE, but it requires a lot more effort and cause severe code bloat if used in many sentences (for example, it's really kills scripted dialogs in my story).

I don't know for sure, but it's implementation will likely require adding only one call of an existing function.

It will benefit writers (including me), who will be able to make better scripts with less effort. Consequently, it will benefits readers, who will get more good stuff.

Parsing variables in a text added by a script

9 years ago
I honestly have no idea what you're asking for. Are you just asking for variables that can hold text?

Parsing variables in a text added by a script

9 years ago

I think Excuse_Me wants on-page coding to work in script language, meaning that something like $PAGETEXT := "%%SEX%=%0%he%%%%SEX%=%1%she%%" would also appropriately parse into "he" or "she".

EDIT: The reason it doesn't do so now is because the on-page code is fired once the page has loaded, which is before the page scripts are executed. The solution might be as "simple" as moving the on-page function, but something tells me it's more complicated than that.

Parsing variables in a text added by a script

9 years ago

Yep, that's exactly what is needed.

Reply to "EDIT": apparently all the user scripts and replacing variable names happens on the server before the page is loaded because there are no traces of text-processing scripts on a page. So this is not the reason.

It seems that parsing of variables is applied to the original page text before the page script is executed. It just needs to be called after the page script, so it will affect the script-adjusted version of the page.

(sorry for a double post, this one was posted after the one below)

Parsing variables in a text added by a script

9 years ago

I'm not sure if you misunderstood, or if I have, or whether you're agreeing with me, so maybe this post is pointless, but what you're saying is basically what I said. Nonetheless, I'll explain my reasoning a bit further. As explained in the Script Code Reference, step 5 is Load Page determined in the Destination, followed by steps 6 and 7, which are Execute Global Page Script and Execute Page Script, respectively. It mentions nothing about the on-page coding, but since it doesn't work with page scripts, it can be assumed that the on-page coding parser is also a part of step 5. There would be no trace of any text-processing scripts, though, because asp.net is a server-side language.

Parsing variables in a text added by a script

9 years ago

There is no contradiction here. What is happening (all on the server side, of course) is quite obvious:

1. The number of page that will be loaded is determined.

2. %%Variables%% in the page text are parsed.

3. Global and local page scripts are executed and they modify the text.

4. Page is sent to a user.

So we just need to parse %%variables%% after the page text is modified by a script. It will likely require a change of only a few lines of code.

Parsing variables in a text added by a script

9 years ago

Yes; though we don't know what the code looks like. We can only hope it's an easy fix.

Parsing variables in a text added by a script

9 years ago

A lot of the code is horrible, since it was written 14 years ago when the alexp was in college.

So it might be much more complicated than you think.

Parsing variables in a text added by a script

9 years ago

I'm asking that a feature already implemented for a text on pages should work in the same way for a text added by a script. You can read about other uses of this feature here: http://chooseyourstory.com/help/articles/article.aspx?ArticleId=3861

Experienced script writers and developers know about it.

String variables would be cool, but I'm not dare to ask for them now. Let at least this small feature be implemented.

Parsing variables in a text added by a script

9 years ago

What differences are there in text code added by script rather than manually?

Parsing variables in a text added by a script

9 years ago

"$PAGETEXT := And then  %%SEX%=%0%he%%%%SEX%=%1%she%% went to the park" would not give desired results.

Parsing variables in a text added by a script

9 years ago

You're not giving any information. What exactly happens? Does it just get shown on the page and not executed? Does it execute incorrectly? Does it not show up?

Parsing variables in a text added by a script

9 years ago
It doesn't execute. The pagetext adds the script as shown to the page.

Parsing variables in a text added by a script

9 years ago

The simplest example: if a variable X has a value 1, then %%X%% in the page text will be replaced with 1. But if you execute $PAGETEXT := "%%X%%" then it will show up as %%X%% instead of 1.

Parsing variables in a text added by a script

9 years ago

Random, but I love your snail avatar.

Parsing variables in a text added by a script

9 years ago

Thanks ^^

Parsing variables in a text added by a script

9 years ago

xD I can't explain why for the life of me, but I smile whenever I see it.

Parsing variables in a text added by a script

9 years ago

Snails are definitely cute. ;P