Tags WDSCRIPT
<WDSCRIPT>...</WDSCRIPT>
Block of w-langage integrated in the HTML page.
Example :
Display date and time
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<BODY bgcolor="white">
<HR><center>DATE AND TIME</center>
<WDSCRIPT>
date is string = datetostring(datesys())
time is string = timetostring(timesys())
<OUT>
Date is : [%date%], time is : [%time%]
</OUT>
</WDSCRIPT>
</HTML>
</BODY>
<OUT>...</OUT>
Send to the generated HTML page.
The variables or function calls must be placed between the tags [% and %]
Example :
Display a table with the content of an HYPERFILE file
<TABLE>
<tr><td>Name</td><td>Age</td></tr>
<WDSCRIPT>
hReadFirst("CLIENT", "NAME")
while h.found
<OUT>
<tr><td>[%CLIENT.NAME%]</td><td>[%CLIENT.AGE%]</td></tr>
</OUT>
hReadNext("CLIENT", "NAME")
End
</WDSCRIPT>
</TABLE>
</HTML>
</BODY>
<WDINCLUDE script.wdsc>
Innclude a w-lnaguage script stored in a .wdsc file (wdscript)
Example :
Call a token management stored in a wdsc file
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<BODY bgcolor="white">
<WDSCRIPT>
<WDINCLUDE GetToken.wdsc>
<OUT>
Token = [%token%]
</OUT>
</WDSCRIPT>
</TABLE>
</HTML>
</BODY>
Content of GetToken.wdsc :
token is string = GetURLField("token")
l is string
if not CheckToken(token) then
l = GetTokenInfo(token, "lang")
DeleteToken(token)
<OUT>
<script language="javascript">
window.location.replace("?page=timeout.html&lang=[%l%]");
</script>
</OUT>
else
RefreshToken(token)
end
WDSCRIPT functions
Abort()
Abort the HTML page generation
AddLog(message)
Add a message in the LOG.TXT file (useful for debugging)
CgiFileName()
Returns the name of the CGI executable (useful to build links)
<a href='[%CgiFilename()%]?page=list.html'>
CheckToken()
Verify if the client's token is valid. Returns a boolean.
DeleteToken()
Delete the client's token, usually at the end of the session.
GetFormField()
Returns the value of a a filed of the form.
Example:
name is string
name = GetFormField("name")
HlitRecherche("CLIENT", "NAME", name)
if h.found then
...
end
GetHtmlUrl()
Returns the URL to access to the HTML folder
Example:
Display an image of the HTML folder :
<img src='[%GetHtmlUrl()%]logo.jpg>
GetMessage(lang, id, global=false)
Translation function. Reads the message in the .mess file (see also PickMessage())
The file containing the messages is named HtmlPageName.mess. GetMessage() opens automatically the file corresponding to the HTML page currently processed.
If global=true, the global.mess is opened (it contains the messages that are global to the application).
Structure of the .mess file:
[LANG1]
id1=message
id1=message
[LANG2]
id1=message
id2=message
Exemple de fichier .mess :
[FR]
title=LISTE DES PERSONNES
Name=Nom
Age=Age
gra=Graphe
[EN]
title=PEOPLE LIST
Name=Name
Age=Age
gra=Graph
Code example :
Display a message attached to the page :
[%GetMessage("FR", "name")%] : [%CL.NAME%]
Display a message attached to the application :
<center>[%GetMessage("FR", "titre", true)%]</center>
GetTempUrl()
Returns the URL to access to the TEMP folder
Example:
Display an image generated in the TEMP folder :
<img src='[%GetTempUrl()%]tmp04938.jpg'>
GetToken()
Create a token identifying the client session. Each access is detected (see RefreshToken()), alowwing to detect a session timeout or the use of a closed session (see CheckToken()).
The token id is a string randomly generated.
Example : Create a token and store data
<WDSCRIPT>
token is string = GetToken()
SetTokenInfo(token, "name", GetFormField("name"))
SetTokenInfo(token, "country", GetFormField("country"))
</WDSCRIPT>
GetTokenInfo()
Retrieves an information previously attached to a session stored in a token.
Example : Retrieve data
<WDSCRIPT>
token is string = GetUrlField("token")
name is string = GetTokenInfo(token, "name")
country is tring = GetTokenInfo(token, "country")
</WDSCRIPT>
GetURLField()
Returns the value of a field of the URL
Example :
token is string = GetUrlField("token")
//URL in format : http://www.toto.com/toto/toto.exe?token=123456
IncludeHTML(FileName)
Include a HTML page.
Example :
Inclusion of a page footer common to all the application.
<WDSCRIPT>
IncludeHTML("foot.html")
</WDSCRIPT>
PickMessage(lang, messages)
Translation function. Returns the message in the choosen language (see also GetMessage())
Contraty to GetMessage(), this function retrieves the translation in the code.
The synrax of the 2nd parameter is : "Lang1=message"+eot+"lang2=message"+eot+"lang3=message"+eot+...
Code example :
Display a message according to the language :
lang is string = GetTokenInfo(GetUrlField("token"), "lang")
<OUT>
[%PickMessage(lang, "FR=Nom"+eot+"EN=Name")%] : [%CL.NAME%]
</OUT>
RefreshToken(token)
Memorize the client access, and restart the timeout counter.
SetTokenInfo()
Stores an information attached to a session previously stored in a token.
Example : Store the value of 2 fields in the data of the session
<WDSCRIPT>
token is string = GetUrlField("token")
SetTokenInfo(token, "name", GetFormField("name"))
SetTokenInfo(token, "country", GetFormField("country"))
</WDSCRIPT>
Pages encryption (sécurity on the Web server)
To ensure the safety of WDSCRIPT code placed on the Web server, it is possible of encrypting HTML and WDSC files.
A encryption tool is placed in the CRYPTO folder :
The encryption key is stored in the constructor of the WDSCRIPT classe, it is possible (even advised) to modify it.
To activate the use of the encrypted files (HTMLC et WDSCC),
you have to modify the first line of the project :
CGI:UseCrypto = True
WDSCRIPT - © Michel FAGES 2000-2001