next up previous contents
Next: Properties Description Up: Overview Previous: Parsing information   Contents

Example

HTML SCRIPT:
Since I'm at it, I will put the syntax to generate an HTML document FROM the MOO itself.

page = {};
page = {page, "$<$HTML$>$"};
page = {page, "$<$BODY$>$"};
page = {page, "$<$FORM METHOD=POST ENCTYPE=multipart/form-data
        ACTION=$\setminus$"http://moo.kcc.hawaii.edu:8888/123/testverb/$\setminus$"$>$"};
page = {page, "Enter the value: $<$INPUT TYPE=TEXT NAME=$\setminus$"var$\setminus$"$>$"};
page = {page, "$<$/FORM$>$"};
page = {page, "$<$/BODY$>$"};
page = {page, "$<$/HTML$>$"};
$kahuna:ok(page);

hopefully, you can see where the line wraps.
So pretty much you create a LIST (in this case called page), you append it with new HTML lines, and when finish, shovel it to $kahuna:ok(page). Note that if you need to insert quotes, you will need a backslash in front of it (see the MOO programmeur's Manual).
The syntax might therefore be kind of repellent... I know, but do not fear, as they is a script available and called :make_HTML(), which can do all this for you, so all you have to do is use your favorite HTML editor, and shovel your HTML into the script to obtain the above.

Now observe what we can do, say on line 4:

page = {page, "$<$FORM METHOD=POST ENCTYPE=multipart/form-data
         ACTION=$\setminus$"http://", $network.site, ":8888/123/testverb/$\setminus$"$>$"};

Do you see it? :)
So, now you can create dynamic Web pages, by embedding any property or verb results obtained from your MOO server and display them along.

Ok, let's go back to the MOO codes that will receive the variable var. Following the above method, I usually start my codes by grabbing and sorting the variables, so I can retrieve them easily when I need to. Example:

MOO Codes:

hash = args[1][2];
env = args[2];
variable = $hash_utils:fetch(hash, "var");
page = {};
page = {page, "$<$HTML$>$"};
page = {page, "$<$BODY$>$"};
page = {page, "You are using ",
    $string_utils:explode($hash_utils:fetch(env, "HTTP_USER_AGENT"), " ")[5],
        " and passed the variable: ", variable, "."};
page = {page, "$<$/BODY$>$"};
page = {page, "$<$/HTML$>$"};
$kahuna:ok(page);

(again, I hope you can see where the line wraps). I know I'm expecting the POST method (hey... we just wrote the HTML), so I'm fetching specifically the POST LIST part, which is args[1][2]. $hash_utils:fetch() is one that can extract easily what you need. I also need something from the environment variables, so I fetched it the same way, explode it through the space character and used the fifth elements, which was the word "Linux".

Happy Coding!!!


next up previous contents
Next: Properties Description Up: Overview Previous: Parsing information   Contents
Kr@nX 666 2004-01-04