![]() |
![]() |
![]() |
DelpWebScriptHTML Embeding |
|
![]() |
Homepage DWS ![]() |
Embeding DWS Scripts in HTML DocumentsTo use this feature of DWS you need a ISAPI or NSAPI module capable to process DWS scripts. If a websurfer requests a link like
this: sendln ('<html>'); This procedure is very uncomfortable and hard to change. It's easier to create HTML pages in a HTML editor and to embed the script in comment tags. In DWS this looks like this: <html> Most actual HTML editors accept <% %> as comment tag and leave them unchanged. But in DWS it's also possible to use <!-- /--> as script tag. If Statements and LoopsIt's possible to use if-statements and loops. <% if true then %> <% for x := 1 to 5 do %> <% Important: The HTML code between two script tags (%> ... <%) is seen as a instruction in DWS. If you use a if-statement or a loop without a begin-end block everything after "then" or "do" is seen as instruction. Example: <% if x = 0 then %> If x is zero only "<p>X is zero!</p>" appears in the output string. Change such code like this: <% if x = 0 then %> ExpressionsA special form of script tag allows you to shortcut the output of expressions of any kind: <p> <% send (text) %> </p> <p><%= text %></p> It's also possible to return more complicated expressions: <p> <%= formatdatetime ('%s:
%d', text, value) %> </p> |