Then step by step:
html()
Displays an HTML formatted string.
Syntax
html([html], [width=600], [height=400], [caption=XYplorer])
BASIC code:
Code: Select all
$myXYVariable = html('
<HTML>
<FORM method="GET" action="xys:">
</FORM>
</HTML>
', "700", "630", "my Windows Title");
$myXYVariable is a XY var to store the result of this XY html() command.
html(' ... ', "700", "630", "my Windows Title"); is the XYplorer command html() itself.
<HTML><FORM method="GET" action="xys:"> ... </FORM></HTML> is the basic HTML code to build the GUI and the function in it.
The key to let this work
is the construction of the FORM tag:
FORM method="GET" action="xys:"
in combination with an
<INPUT type="submit" button. (for how to use a link see below at the end)
For example:
Code: Select all
$myXYVariable = html('
<HTML>
<FORM method="GET" action="xys:">
Hello World!<BR>
<BR>
Between the HTML tag, there is standard HTML code<BR>
<BR>
<BR>
<INPUT type="submit" name="Submit" value="The OK button">
</FORM>
</HTML>
', "700", "630", "my Windows Title");
Add some HTML code to add some functionality:
Code: Select all
$TextAreaDefault = "One<crlf>Two<crlf>Three";
$myXYVariable = html('<HTML><FORM method="GET" action="xys:">
Hello World!<BR>
<TEXTAREA name="BigTextArea" rows=6 cols=75>' . $TextAreaDefault . '</TEXTAREA><BR>
<INPUT type="radio" name="myOption" value="Option1" checked> Option 1
<INPUT type="radio" name="myOption" value="Option2" > Option 2 <BR> <BR>
Option5: <input type="text" name="Option5" size="80" Value=""> <BR>
Option6: <input type="text" name="Option6" size="80" Value=""> <BR>
<BR><BR><BR>
<INPUT type="submit" name="Submit" value="The OK button">
</FORM></HTML>', "700", "630", "my Windows Title");
Awaited result (resized):

- Add some HTML code to add some functionality:
- step1-75p.png (17.21 KiB) Viewed 4329 times
Work up the result:
Execute the script and enter some data and/or chose one or another option. Then...
1.) Discern between [Cancel] or [Submit] is clicked by user:
Code: Select all
//####################### // get and work up the results:
// IF the [Close]-button is pressed instead of the [Submit]-button:
IF ($myXYVariable==""){
msg "cancel pressed";
END 1==1; //quit whole script
}
//else
msg "The command resulted in:<crlf 2>" . $myXYVariable;
msg "Just a test: i am still here!"; //you will not see this if cancel was clicked.
//end of script
2.)
IF [Submit] button (labelled here with "The OK button") was clicked, we get an return like this:
?
BigTextarea=One%0D%0ATwo%0D%0AThree&myOption=Option1&
Option5=&Option6=&
Submit=The+OK+button
That can be split at the ampersand sign like:
?
BigTextarea=One%0D%0ATwo%0D%0AThree
&
myOption=Option1
&
Option5=
&
Option6=
&
Submit=The+OK+button
Lets do that with XYplorer script:
Code: Select all
//#### Now split the result of $myXYVariable into parts at the '&' sign:
// split at the '&' sign and give me part No. 1
$ResultOfTheTextArea = gettoken($myXYVariable, "1", "&");
// debug test:
msg "Splitted 1. part at the &:<crlf>" . $ResultOfTheTextArea;
That in return can be split at the equal sign like:
BigTextarea=One%0D%0ATwo%0D%0AThree
myOption=Option1
Option5=
Option6=
Submit=The+OK+button
Lets do that with XYplorer script:
Code: Select all
// now split this $ResultOfTheTextArea into parts at the '=' sign and give me part No. 2
$ResultOfTheTextArea = gettoken($ResultOfTheTextArea, "2", "=");
// debug test:
msg "That 1. part splitted at the =:<crlf>" . $ResultOfTheTextArea;
// now do this for every part of the result, increasing the part number in the first gettoken() command:
gettoken($myXYVariable, "2", "&");
instead of
gettoken($myXYVariable, "1", "&");
Code: Select all
// split at the '&' sign and give me part No. 2
$ResultOfMyOption = gettoken($myXYVariable, "2", "&");
// debug test:
msg "Splitted 2. part at the &:<crlf>" . $ResultOfMyOption;
// now split this $ResultOfTheTextArea into parts at the '=' sign and give me part No. 2
$ResultOfMyOption = gettoken($ResultOfMyOption, "2", "=");
// debug test:
msg "That 2. part splitted at the =:<crlf>" . $ResultOfMyOption;
Now go on and on for each object of your HTML page:
// split at the '&' sign and give me part No. 3
$ResultOfMyOption = gettoken($myXYVariable, "3", "&");
....followed by the rest code as shown above....
// split at the '&' sign and give me part No. 4
$ResultOfMyOption = gettoken($myXYVariable, "4", "&");
....followed by the rest code as shown above....
and so on...
Of course you have to know a fair bit of the HTML language.
But in general, behind the equal sign is what the user have chosen or entered into the HTML form.
And each part of the submitted result was delimited by an ampersand sign.
3.) At the end you have to decide what to do with the result:
Code: Select all
//#### do something with that result:
if($ResultOfMyOption=="Option1") {msg "you opt for option 1?";} else {msg "you opt for option 2?";}
Instead of just showing a MsgBox you of course want to do more interesting things, don't you
END of this little explanation.
########################
Here are the parts of my example script from above in a whole just for your convenience:
Code: Select all
$TextAreaDefault = "One<crlf>Two<crlf>Three";
$myXYVariable = html('<HTML><FORM method="GET" action="xys:">
Hello World!<BR>
<TEXTAREA name="BigTextArea" rows=6 cols=75>' . $TextAreaDefault . '</TEXTAREA><BR>
<INPUT type="radio" name="myOption" value="Option1" checked> Option 1
<INPUT type="radio" name="myOption" value="Option2" > Option 2 <BR> <BR>
Option5: <input type="text" name="Option5" size="80" Value=""> <BR>
Option6: <input type="text" name="Option6" size="80" Value=""> <BR>
<BR><BR><BR>
<INPUT type="submit" name="Submit" value="The OK button">
</FORM></HTML>', "700", "630", "my Windows Title");
//####################### // get and work up the results:
// IF the [Close]-button is pressed instead of the [Submit]-button:
IF ($myXYVariable==""){
msg "cancel pressed";
END 1==1; //quit whole script
}
//else
msg "The command resulted in:<crlf 2>" . $myXYVariable;
// That is on our test:
// ?BigTextarea=One%0D%0ATwo%0D%0AThree&myOption=Option1&Option5=&Option6=&Submit=The+OK+button
//#### Now split the result of $myXYVariable into parts at the '&' sign:
// split at the '&' sign and give me part No. 1
$ResultOfTheTextArea = gettoken($myXYVariable, "1", "&");
// debug test:
msg "Splitted 1. part at the &:<crlf>" . $ResultOfTheTextArea;
// now split this $ResultOfTheTextArea into parts at the '=' sign and give me part No. 2
$ResultOfTheTextArea = gettoken($ResultOfTheTextArea, "2", "=");
// debug test:
msg "That 1. part splitted at the =:<crlf>" . $ResultOfTheTextArea;
//#### now do this for every part of the result, increasing the part number in the first gettoken() command:
// split at the '&' sign and give me part No. 2
$ResultOfMyOption = gettoken($myXYVariable, "2", "&");
// debug test:
msg "Splitted 2. part at the &:<crlf>" . $ResultOfMyOption;
// now split this $ResultOfTheTextArea into parts at the '=' sign and give me part No. 2
$ResultOfMyOption = gettoken($ResultOfMyOption, "2", "=");
// debug test:
msg "That 2. part splitted at the =:<crlf>" . $ResultOfMyOption;
//#### do something with that result:
if($ResultOfTheTextArea != ""){msg "the area contains " . $ResultOfTheTextArea; // do some work....}
if($ResultOfMyOption=="Option1") {msg "you opt for option 1?";} else {msg "you opt for option 2?";}
msg "Just a test: i am still here!"; //you will not see this if cancel was clicked.
//end of script
- - -
URL Links
To use URL links in your HTML page use the
xys advice like:
<a href="xys: myURLone">Execute One</a>
The follow up code to proceed with this is something like:
Code: Select all
// IF an link is clicked
IF ($myXYVariable == "myURLone") {
msg "Link One was pressed";
}
For example:
Code: Select all
$myXYVariable = html('
<HTML>
<a href="xys: myURLone">Execute One</a>
<FORM method="GET" action="xys:">
Hello World!<BR>
<INPUT type="submit" name="Submit" value="The OK button">
</FORM>
</HTML>
', "700", "630", "my Windows Title");
// IF the [Close]-button is pressed instead of the [Submit]-button:
IF ($myXYVariable==""){
msg "cancel pressed";
END 1==1; //quit whole script
}
// IF an link is clicked
IF ($myXYVariable == "myURLone") {
msg "Link One was pressed";
// do some work....
} else {
//split the result into parts (see above)
// do some work....
}
HTH?