Saturday, July 28, 2007

Python - HTA : Simple Wizard


Voici comment afficher des pages contenues dans de simples fichiers texte.
Très pratique pour écrire par exemple, des assistants


Fichier tutorhta.txt (servant dans le script tutor.hta)

%pywizard%
%
<h1>Introduction</h1>
D'apr&egrave;s l'article de microsoft :
<a href="http://msdn2.microsoft.com/en-us/library/bb264002.aspx">Getting Your Page's Data into a Bind</a>
%
%
<h2>Chapitre 1</h2>
%
%
<h2>Chapitre 2</h2>
%

fichier tutor.hta

<html>
<head>
<OBJECT ID="Content" WIDTH=0 HEIGHT=0
CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="TextQualifier" VALUE="%">
<PARAM NAME="FieldDelim" VALUE="|">
<PARAM NAME="DataURL" VALUE="tutorhta.txt">
<PARAM NAME="UseHeader" VALUE="true">
</OBJECT>
</head>
<body style="font-family: verdana">

<span style="font-weight: bold; cursor: hand" onclick="goBackward()"><<</span>
Python - HTA
<span style="font-weight: bold; cursor: hand" onclick="goForward()">>></span>
<br>
<span id=Status></span><br>
<div id=TheStory datasrc=#Content datafld="pywizard" dataformatas="HTML"></div>

<SCRIPT language=Python>

doc = document.all
rs = None

def goForward():
global rs
if (rs.absolutePosition != rs.recordCount) :
rs.MoveNext()
else :
rs.MoveFirst()

def goBackward():
global rs
if (rs.absolutePosition > 1) :
rs.MovePrevious()
else :
rs.MoveLast()

def initialize():
global rs
rs=doc.Content.recordset;


window.onload = initialize()

</SCRIPT>
</body>
</html>

No comments:

Post a Comment