eBook authors eBook Software - create and publish your own ebooks
Create your own eBooks
Learn How To Create, Publish & Market E-Books
E-Book Creation Software
Add sophisticated multimedia to your E-Books
Create E-Book covers in minutes
E-Book Marketing & Promotion made easy
Search engine for E-Books
Interviews with eBook authors
Tools for building better eBooks
Archived Message:

Script Variable wont display

kinL Hi, I'm a new Activ E-book user and just getting into Activ Script, but I'm struggling with what seems like the simplest of scripting tasks!

I have a mixture of non-protected and protected pages in my e-book and have created a very simple script that uses the SET statement to set a string variable called pwdbutton', the intention being to display an 'Enter Password' button on my Contents page if the password for the book has not yet been entered.

The script is as follows:

SET('pwdbutton','<div class={doublequote}floatright{doublequote}><a href={doublequote}##ENTERPASSWORD(){doublequote} title={doublequote}click to enter your password for this ebook{doublequote}><img src={doublequote}enterPassword.gif{doublequote} alt={doublequote}click to enter your password for this ebook{doublequote} /></a></div>')

I am executing the script through the 'On Start' Event Handler.

The Preprocessor is set ON for ALL HTML files.

In my HTML I refer to my variable using the [={pwdbutton}] notation.

When I compile and view the page all I see is [={pwdbutton}], not the value that I set the variable to in the script.

I am a seasoned programmer of some 20 years but this is frustrating the hell out of me!

Any advice greatly appreciated.


Posted on: 4:28 pm on March 19, 2007
rlemire KinL;

I'm a little confused by your code.

This doesn't look like a variable to me. It looks more like a "script" function.

If I'm not mistaken, setting a variable should look like....

myURL = "http://thisismywebsite.com"

and you probably need to set it up in the Activ Variable list to be able to call it using.


I probably will be corrected, but, if you want to call a function from all of your page you might need to place it in an external js. file and call it from the head of each documents. something like this...

<SCRIPT LANGUAGE="JavaScript" SRC="myscript.js">

This setup will allow each document to call the routine as required.

Here is some better "inline" code to call up the "enter password" routine'

<a href= "#stop" onClick="window.external.ActivRun('##ENTERPASSWORD()'); return false"> Click here to enter your password </a></div>

On a previous post you seemed to have reservations about using JavaScript because some people might have it disabled. These days JavaScript/VBScript  is the "norm" for Internet navigation and ecommerce. Without JavaScript most modern sites would not function. Anyone who operates their browser with JavaScript disabled has  a very boring Internet experience.

For example in the code to open the "ENTERPASSWORD()" routine. You could use JavaScript, not only to call the function, but also "NOT" call the function if a password was already entered.

BTW: One way to "Set" an Activ Variable "inline" probably would look something like this...

< script> window.external.ActivSet('myURL','http://thisismywebsite.com'); </script></div>

Personally, I would handle all of this in a JavaScript function....


Posted on: 8:33 pm on March 19, 2007
kinL Hi Ron, thanks for you reply and I understand your comments re. JavaScript, etc.

I think I must be missing a big point here... the Active E-book help text states:

The following example would set the value of a variable called foo to 4, a variable called bar to hello, and a variable called myvariable to hello world:

SET('myvariable', '{bar} world')

With the above example I was simply trying to use the SET statement to assign a string (albeit in this case a block of HTML code) to a variable.  I am conditioning this within an IF...ENDIF block that checks the {iscorrectpassword} variable to see if the password has been entered or not, if it has the script would just assign a blank to my variable.

Does this mean that the 'SET' statement doesn't actually work?

I have also tried several of the other string manipulation statements (STRCAT, STRHTML, etc.) but none seem to set a 'Script Variable'.

Much appreciate you further thoughts.


Posted on: 10:05 pm on March 19, 2007
rlemire kinL;

I now understand a little better where you are.

These "SET" statements are to be run in an Activ Script file, usually designated with an ".as" file extension.

These script files are usually included with your eBook much like a ".js" file.

To use these scripts in your HTML code you need to "link" to them using a specific format.

For internal scripts it would be something like

<A HREF="#!test.as">Click here to run test.as</A> to access a file called "test.as"

for example:

the statements

SET('myvariable', '{bar} world')

Could be saved as a text file called i.e. "SETit.as" then you would "run" the "SETit" file using

<A HREF="#!SETit.as">Click here to SET the variables</A>

This would "SET" the variables so you could later "GET" them and use them for whatever...

In "Immediate" mode you would use something like

<A HREF="##MESSAGEBOX('In a moment we will search')##SEARCH()">Click Here</A>

This information is found in the Activ E-Book help section

Activ Script / Activ Links /

To use Activ Scripts you need to read just about everything in the Activ Script Section.

Activ ".as" files can be used in many amazing ways, but personally I'm partial to using JavaScript to run Activ Script in the "Immediate" mode.


Posted on: 3:10 am on March 20, 2007
kinL Hi Ron, thanks for coming back to me and you are correct in how I am trying to use the SET statement.

I had saved the script (posted earlier) in a file called 'startup.as' and set the 'On Start' Event Handler to execute it, the actual entry in the event handler being "#!startup.as".

I also checked that the script was actually executing when launching the e-book by adding a 'NAVIGATE' statement and this checks out, it just seems to ignore my 'SET' statement.

I have even included my script file in an Activ Link within my index.htm page with <A HREF="#!startup.as">Click Here</A>, the result was just the same.

I don't think this is anything to do with the fact that I am trying to SET a variable with a block of HTML code, the code is just the string value that I am trying to assign to the variable. If I modify my startup.as file to contain one very simple SET statement, like


I get exactly the same result in my e-book page as previously noted, i.e. [={pwdbutton}]

Here's another example using the SET statement, this one from the ebookcode.com website:


Look at the statements in the section "build a long string of the text", you'll see that I'm not trying to do anything complex compared to this!

I think basically the SET statement doesn't work and I think this is the problem that lee was having too ( ref:http://www.ebookfriends.com/cgi-bin/ikonboard/topic.cgi?forum=1&topic=790&start=0).

I'm resigning myself to using JavaScript as you previously suggested but I am very dissappointed that even such a simple statement doesn't work, what else I wonder?

Thank you for taking the time to respond. I will take this up with Answers 2000 to see if they can shed any light and will post their response.

Best regards

Posted on: 8:04 pm on March 20, 2007
rlemire kinL;

I know the SET statements work, I use it all the time, but not in this way.

Here is what I think the problem is.

You are trying to use preprocessor to display the variable you are creating with the SET statement. The problem stems from a misunderstanding of what happens when your eBook is compiled.
Preprocessor means exactly that pre-processor. That means it will propagate some existing data into all the HTML pages where you use the preprocessor code. i.e. [={title}]

By its very definition any variable value you are trying to display using preprocessor, must exist before the eBook is compiled.

If you SET a value in an "as" file, that value comes into reality after the eBook is compiled and therefore could never be pre-processed.

To be able to use the value below in preprocessor i.e.

You would need to add a variable "pwdbutton" in the Activ Variable list
i.e. Edit/Activ Variable/Add Variable. and "cut and paste" the text below as a value.

<div class="floatright"><a href="##ENTERPASSWORD()" title=" click to enter your password for this ebook"><img src="enterPassword.gif" alt="click to enter your password for this ebook /></a></div>


Posted on: 1:25 am on March 21, 2007
EBookCompiler Ron's last post, I think pretty much answers the question.

The only thing that I would add, is if you want to display a variable that changes inside your HTML, you can use the DISPLAY statement - but then you have to display the whole page

Posted on: 12:21 pm on March 21, 2007


List All Archived Forums

Copyright © 2000-2018, Answers 2000 Limited.

With any business, it is up to the individual owner of said business to ensure the success of the business. You may make more or less than any sample figures or results that might be quoted on our web sites or other publications. All business involves risk, and many businesses do not succeed. Further, Answers 2000 Limited does NOT represent that any particular individual or business is typical, or that any results or experiences achieved by any particular individual/business is necessarily typical.

Disclosure: Our company's websites' content (including this website's content) includes advertisements for our own company's websites, products, and services, and for other organization's websites, products, and services. In the case of links to other organization's websites, our company may receive a payment, (1) if you purchase products or services, or (2) if you sign-up for third party offers, after following links from this website. Unless specifically otherwise stated, information about other organization's products and services, is based on information provided by that organization, the product/service vendor, and/or publicly available information - and should not be taken to mean that we have used the product/service in question. Additionally, our company's websites contain some adverts which we are paid to display, but whose content is not selected by us, such as Google AdSense ads. For more detailed information, please see Advertising/Endorsements Disclosures

Our sites use cookies, some of which may already be set on your computer. Use of our site constitutes consent for this. For details, please see Privacy.

Click privacy for information about our company's privacy, data collection and data retention policies, and your rights.

Contact Us    About and Terms Of Use    Privacy    Advertising/Endorsements Disclosures