This simple tool is included in the Development tools supplied
with ALP (Active Local Pages). Here is the source code:
<%
Dim sf, cf, msgs, bSuccess
Set sf = Server.CreateObject("newObjects.utilctls.SFMain")
Set cf = Server.CreateObject("newObjects.utilctls.ConfigFile")
Set msgs = Server.CreateObject("newObjects.utilctls.VarDictionary")
bSuccess = True
Function ReadScriptFile(file, path)
On Error Resume Next
Dim pos, f, inf, sfile
pos = InStr(file,"\")
If pos > 0 Then
sfile = file
Else
sfile = path & file
End If
Set inf = sf.OpenFile(sfile,&H40)
If Err.Number <> 0 Then
msgs.Add "", "Failed to open file: " & sfile
bSuccess = False
Else
ReadScriptFile = inf.ReadText(-1)
inf.Close
End If
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<link REL="stylesheet" HREF="styles.css">
<title>DevTools</title>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#EDF3F3">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td width="100%" valign="bottom" align="right" class="bigFont" style="border-bottom: 1 solid rgb(0,0,0)" background="head.gif">
Composite Definition Converter
</td>
</tr>
<tr>
<td width="100%" align="left" valign="top" height="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="5" height="100%">
<tr>
<TD width="100%" align="left" valign="top" height="100%">
<% If Request.ServerVariables("REQUEST_METHOD") = "POST" Then %>
<%
Dim infile, outfile, path, filecontent
infile = CStr(Request.Form("INFile"))
If Len(infile) < 4 Then
%>Please select input file<%
Else
path = sf.GetFilePath(infile)
Dim cfg
On Error Resume Next
Set cfg = cf.Read(infile)
If Err.Number <> 0 Then
%>Cannot read the input file<%
Else
outfile = path & Request.Form("OUTFile")
' Do convert
On Error GoTo 0
Dim comps, comp, f, I, J
Set comps = cfg("COMPONENTS")
For I = 1 To comps.Count
Set comp = comps(I)
comp.Remove "Script"
If UCase(comp("Type")) = "SCRIPT" Then
If IsObject(comp("File")) Then
For J = 1 To comp("File").Count
f = comp("File")(J)
comp.Add "Script", ReadScriptFile(f,path)
Next
End If
End If
Next
If bSuccess Then
cf.Write outfile, cfg
%>Conversion successful<%
Else
%><B>There are errors</B><BR><%
For I = 1 to msgs.Count
Response.Write msgs(I) & "<BR>"
Next
End If
End If
End If
%>
<HR SIZE=1 COLOR=0>
<A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>">Convert another</A>
<% Else %>
<FORM METHOD="POST" ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>">
<P>
Select the file to convert. It must be a composite object
definition in text format.<BR>
<INPUT TYPE="FILE" NAME="INFile" CLASS="ifield"><BR>
Specify the output file name (it will be placed in the
same directory):<BR>
<INPUT TYPE="TEXT" NAME="OUTFile" VALUE="objectdef.comp" CLASS="ifield"><BR>
<INPUT TYPE="SUBMIT" VALUE="Convert">
</p>
</FORM>
<% End If %>
</TD>
</TR>
</table>
</td>
</tr>
</table>
</body>
</html>
Notes: The sample is designed for ALP. However this
ASP page will work correctly on IIS if used from the localhost
only.
|