Formatting code for JumpToSample
=====How to add a "Jump To" command?=====
~&HTML Executable User Question:---Is it possible to insert a "goto command" anywhere in the book.---I really want to give users the chance to jump to any page in the book.
With a single HEScript custom function, you can achieve this goal. Then it is possible to call this HEScript directly from your pages (with JavaScript or links), a custom menu command or a toolbar button. In this sample, we'll create a "Jump to" toolbar button.
First you need to write the HEScript function that asks the user for the page she/he wants to display:
- Open your HTML Executable project and select the "**Behavior & Scripting**" tab.{{image class="center" alt="folder" title="folder" url="images/ep/p0.png"}}Then double-click on the "UserMain" script to open the script editor as shown on the figure.
- In the script editor, insert a new script Boolean function called "//JumpToChapter//" (you can give it another name but remember it in that case) and paste the script available below; click on **Save**. The editor is closed.
%%(pascal)
function JumpToChapter: Boolean;
var
S1: String;
i: integer;
begin
Result := True;
// Asks the user for the page he wants to see.
S1 := InputBox("Please enter the number of the page you want to see:", "Jump to", "1");
// Checks if cancel.
if S1 = "" then exit;
// Checks if the page is correct by converting the string to an integer.
i := strtointdef(S1 ,0);
// Creates the page's name.
if i < 10 then
S1 := "page000" + inttostr(i)
else if i < 100 then
S1 := "page00" + inttostr(i)
else if i < 1000 then
S1 := "page0" + inttostr(i)
else
S1 := "page" + inttostr(i);
// Adds the remaining part (extension)
S1 := S1 + ".html";
// Displays the page
GoToPage(S1, "");
end;
%%
Note that in this sample, the pages have the following filename format: //pg_0001.html, pg_0002.html, pg_0003.html// and so on. You can customize that by modifying the script above.
Click on **Save** and that's all.
Now we can create a custom toolbar button.{{image class="center" alt="folder" title="folder" url="images/ep/p4.png"}}
Add a new custom button using **Add**.{{image class="center" alt="folder" title="folder" url="images/ep/p5.png"}}
When the button is clicked, the JumpToChapter function will be executed.
It asks your user to enter the number of the page that should be displayed:{{image class="center" alt="folder" title="folder" url="images/ep/p6.png"}}
When the user clicks OK, the page is automatically displayed.
**See this link about how to call your script function using different ways:**
[[http://help.htmlexe.com/index.php?show=callscript.htm help.htmlexe.com/index.php?show=callscript.htm]]
~&HTML Executable User Question:---Is it possible to insert a "goto command" anywhere in the book.---I really want to give users the chance to jump to any page in the book.
With a single HEScript custom function, you can achieve this goal. Then it is possible to call this HEScript directly from your pages (with JavaScript or links), a custom menu command or a toolbar button. In this sample, we'll create a "Jump to" toolbar button.
First you need to write the HEScript function that asks the user for the page she/he wants to display:
- Open your HTML Executable project and select the "**Behavior & Scripting**" tab.{{image class="center" alt="folder" title="folder" url="images/ep/p0.png"}}Then double-click on the "UserMain" script to open the script editor as shown on the figure.
- In the script editor, insert a new script Boolean function called "//JumpToChapter//" (you can give it another name but remember it in that case) and paste the script available below; click on **Save**. The editor is closed.
%%(pascal)
function JumpToChapter: Boolean;
var
S1: String;
i: integer;
begin
Result := True;
// Asks the user for the page he wants to see.
S1 := InputBox("Please enter the number of the page you want to see:", "Jump to", "1");
// Checks if cancel.
if S1 = "" then exit;
// Checks if the page is correct by converting the string to an integer.
i := strtointdef(S1 ,0);
// Creates the page's name.
if i < 10 then
S1 := "page000" + inttostr(i)
else if i < 100 then
S1 := "page00" + inttostr(i)
else if i < 1000 then
S1 := "page0" + inttostr(i)
else
S1 := "page" + inttostr(i);
// Adds the remaining part (extension)
S1 := S1 + ".html";
// Displays the page
GoToPage(S1, "");
end;
%%
Note that in this sample, the pages have the following filename format: //pg_0001.html, pg_0002.html, pg_0003.html// and so on. You can customize that by modifying the script above.
Click on **Save** and that's all.
Now we can create a custom toolbar button.{{image class="center" alt="folder" title="folder" url="images/ep/p4.png"}}
Add a new custom button using **Add**.{{image class="center" alt="folder" title="folder" url="images/ep/p5.png"}}
When the button is clicked, the JumpToChapter function will be executed.
It asks your user to enter the number of the page that should be displayed:{{image class="center" alt="folder" title="folder" url="images/ep/p6.png"}}
When the user clicks OK, the page is automatically displayed.
**See this link about how to call your script function using different ways:**
[[http://help.htmlexe.com/index.php?show=callscript.htm help.htmlexe.com/index.php?show=callscript.htm]]