Script Tutorial Request for sc HTML, INIT/Terminate
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Script Tutorial Request for sc HTML, INIT/Terminate
Hi.
Can someone please provide a tutorial displaying how to deal with sc HTML and "Initialize and Terminate" (Help file: Multi-line Scripts and Multi-Scripts, rtfm "idh_scripting.htm#idh_scripting_multi";), step by step, features show-off?
Thanks in advance.
Can someone please provide a tutorial displaying how to deal with sc HTML and "Initialize and Terminate" (Help file: Multi-line Scripts and Multi-Scripts, rtfm "idh_scripting.htm#idh_scripting_multi";), step by step, features show-off?
Thanks in advance.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Here are some basics shown at an Example Framework for the XYplorer-script HTML() function
http://www.xyplorer.com/xyfc/viewtopic. ... 856#p49856
Which questions do you still have?
.
http://www.xyplorer.com/xyfc/viewtopic. ... 856#p49856
Which questions do you still have?
.
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Everything.
I've never got the codes to return nothing when I've adapted some HTML codes I got here on forums. Once I failed to produce a simple 2 buttons, 3 input lines code then I left the whole thing aside. And I know I could do more with such a knowledge, as over time I've been capable of producing very complex scripts - and simple solutions for complex problems.
I've never got the codes to return nothing when I've adapted some HTML codes I got here on forums. Once I failed to produce a simple 2 buttons, 3 input lines code then I left the whole thing aside. And I know I could do more with such a knowledge, as over time I've been capable of producing very complex scripts - and simple solutions for complex problems.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Then step by step:
BASIC code:
$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:
Add some HTML code to add some functionality:
Awaited result (resized):
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:
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:
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:
// 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", "&");
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:
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:
- - -
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:
For example:
HTH?
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");
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");
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?";}

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....
}
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Thanks very much, Stefan! Will study it tonight.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Sorry this is a VERY SIMPLE script but hey, it uses HTML!
All is does is open up a nice HTML window to give you more information on the selected file extension.
Code: Select all
$EXT = GetPathComponent(<curitem>,"ext");
$EXT = Recase("$EXT","upper");
Html("http://filext.com/file-extension/"."$EXT", "85%", "85%", "File Extension Info - "."$EXT");
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Tutorial Request for sc HTML, INIT/Terminate
@Enternal:
Thanks - this is also a perfect example (I should have known a time ago for another situation! Damn! lol).
@Stefan:
Great.
It seems I've got the principles. But I'm stuck at this: how do I get a variable correctly processed into the sc html portion?
Using heredoc like in
I managed to (is that right?
) ensure that $myXYVariable is filled with a valid target.
But
' ', "700", "630", "my Windows Title"' is displayed at the lower portion of the HTML interface
and a " ' ", at the left of the "Execute One". How do I fix that...?
Thank you very much!
-any example on how to work with Initialize/Terminate, Stefan or anyone else...?
Thanks - this is also a perfect example (I should have known a time ago for another situation! Damn! lol).
@Stefan:
Great.
It seems I've got the principles. But I'm stuck at this: how do I get a variable correctly processed into the sc html portion?
Using heredoc like in
Code: Select all
step;
$tgt = "http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10275";
$a = <<<heredoc
'
<HTML>
<a href="xys:$tgt">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"
heredoc;
$myXYVariable = html("$a"); // heredoc saved the day - variable wouldn't be processed otherwise!
// IF the [Close]-button is pressed instead of the [Submit]-button:
IF ($myXYVariable==""){
msg "cancel pressed";
END 1==1; //quit whole script
}
step;
// IF an link is clicked
IF ($myXYVariable == "$tgt") {
msg "Link One was pressed";
// do some work....
} else {
//split the result into parts (see above)
echo "oops!";
// do some work....
}

But
' ', "700", "630", "my Windows Title"' is displayed at the lower portion of the HTML interface
and a " ' ", at the left of the "Execute One". How do I fix that...?
Thank you very much!
-any example on how to work with Initialize/Terminate, Stefan or anyone else...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: Script Tutorial Request for sc HTML, INIT/Terminate
I'm afraid that html("$a") only gives one operand to the html-function, while I think you also want to supply width, height and caption?
So I think you should move the latter from inside the heredoc to html($a, 700, 630, "my Windows Title").
(You may add the unneeded quotes again
)
So I think you should move the latter from inside the heredoc to html($a, 700, 630, "my Windows Title").
(You may add the unneeded quotes again


W7(x64) SP1 German
( +WXP SP3 )
( +WXP SP3 )
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Tutorial Request for sc HTML, INIT/Terminate
Thank you, PeterH! That solved.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: Script Tutorial Request for sc HTML, INIT/Terminate
I'm glad to hear thatSkyFrontier wrote:Thank you, PeterH! That solved.

W7(x64) SP1 German
( +WXP SP3 )
( +WXP SP3 )