see changelog

This commit is contained in:
Eddie Runia
1999-06-15 22:03:11 +00:00
parent 520607e094
commit fd10cf24fb
10 changed files with 492 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
19990615-23:00 CET Felipe Coury
+ tests/working/hscript/bld32exe.bat; dir.hs; hb32.bat; hello.hs;
hscript.prg; makehs.prg; makehtm.prg; multiply.hs readme.txt
First release of hScript added
19990615-21:00 CET Jose Lalin / Eddie Runia
+ source/rtl/natmsg/msgbas.c
* source/rtl/msgxxx.c

View File

@@ -0,0 +1,27 @@
@echo off
IF A%1 == A GOTO :SINTAX
IF A%2 == A GOTO :NOOUTPUT
echo -O2 -e%2.exe -I..\..\..\include ..\..\..\source\vm\hvm.c %1.c > b32.bc
echo ..\..\..\libs\b32\harbour.lib ..\..\..\libs\b32\terminal.lib >> b32.bc
echo ..\..\..\libs\b32\hbgt.lib >> b32.bc
bcc32 @b32.bc
del b32.bc
GOTO :END
:NOOUTPUT
echo -O2 -e%1.exe -I..\..\..\include ..\..\..\source\vm\hvm.c %1.c > b32.bc
echo ..\..\..\libs\b32\harbour.lib ..\..\..\libs\b32\terminal.lib >> b32.bc
echo ..\..\..\libs\b32\hbgt.lib >> b32.bc
echo runner.obj >> b32.bc
bcc32 @b32.bc
del b32.bc
GOTO :END
:SINTAX
ECHO syntax: BuildExe Harbour_Output_Filename [Exe_Output_Filename]
ECHO Use Harbour_Output_Filename and Exe_Output_Filename without extensions
ECHO\
:END

View File

@@ -0,0 +1,46 @@
<%
FUNCTION Main()
LOCAL aDir := directory( "c:\*.*" )
LOCAL i
IF !empty( GetEnv( "SERVER_NAME" ) )
qqOut( "HTTP/1.0 200 OK" )
qOut( "CONTENT-TYPE: TEXT/HTML" )
qOut( "" )
ENDIF
aSort( aDir,,, { |x, y| x[1] < y[1] } )
%>
<HTML>
<HEAD><TITLE>dir.hs - HarourScript demo of active context</TITLE></HEAD>
<BODY>
<TABLE border=1>
<TR>
<TD><B>File Name</B></TD>
<TD><B>Size</B></TD>
<TD><B>Date</B></TD>
<TD><B>Time</B></TD>
<TD><B>Attributes</B></TD>
</TR>
<%
FOR i := 1 TO len( aDir )
%>
<TR>
<TD><% qOut( aDir[i,1] ) %></TD>
<TD><% qOut( aDir[i,2] ) %></TD>
<TD><% qOut( aDir[i,3] ) %></TD>
<TD><% qOut( aDir[i,4] ) %></TD>
<TD><% qOut( aDir[i,5] ) %></TD>
</TR>
<%
NEXT
%>
</TABLE>
</BODY>
</HTML>
<%
RETURN( NIL )
%>

View File

@@ -0,0 +1,10 @@
@echo off
REM From .PRG to .C = Harbour
..\..\..\bin\harbour %1.prg /n /i..\..\..\include
if errorlevel 1 goto end
REM From .C to .EXE = BuildExe
call BLD32EXE %1 %2
:end

View File

@@ -0,0 +1,38 @@
<%
/*
*
* hello.hs
* Famous "Hello World"!
*
*/
FUNCTION Main()
// Add content-type parameter if using active page on a Web Server
IF !empty( GetEnv( "SERVER_NAME" ) )
qqOut( "HTTP/1.0 200 OK" )
qOut( "CONTENT-TYPE: TEXT/HTML" )
qOut( "" )
ENDIF
%>
<HTML>
<HEAD>
<TITLE>Hello world!</TITLE>
</HEAD>
<BODY>
<%
// Now saying hello to the world in 3 different ways:
// 1. Pure harbour:
qOut( "<H1>Hello world!</H1></P>" )
// 2. Hybrid harbour-html:
%>
<H1><% qOut( "Hello world!" ) %></H1></P>
<%
// 3. Pure html:
%>
<H1>Hello world!</H1></P>
</BODY>
</HTML>

View File

@@ -0,0 +1,187 @@
/*
*
* HScript.PRG
* HarbourScript translator
*
* 1999/06/13 First implementation.
*
**/
#include "CGI.ch"
#define IF_BUFFER 65535
#define NewLine chr(13)+chr(10)
FUNCTION Main( cScript )
LOCAL aHRSHandle := {} // Handle for script lines
LOCAL aResult := {} // Handle for transl'd lines
LOCAL cLocation := {} // Location of scripts
LOCAL cHarbourDir := GetEnv( "HARBOUR_DIR" ) // Harbour.exe dir with '\'
LOCAL cHost := strtran( alltrim( ; // Random (not et al)
str( seconds() ) ), '.' ) // file name
LOCAL cScriptName, cFile, cRes, cLine
LOCAL hFile, nStartPos, nPos, i, lScriptFlag
WHILE .t.
IF empty( GetEnv( "SERVER_NAME" ) )
cScriptName := cScript
cLocation := GetEnv( "PATH_TRANSLATED" ) + ;
strtran( GetEnv( "SCRIPT_NAME" ), "/", "\" )
cLocation := substr( cLocation, 1, rat( "\", cLocation ) )
cHarbourDir := cLocation
ELSE
cScriptName := GetEnv( "QUERY_STRING" )
IF at( "=", cScriptName ) != 0
cScriptName := ParseString( cScriptName, "=", 2 )
ENDIF
ENDIF
IF empty( cScriptName )
IF !empty( GetEnv( "SERVER_NAME" ) )
qqOut( "content-type: text/html" )
qOut( "" )
qOut( "<HTML><BODY><H1>Server Error</H1><P>" )
qOut( "Must specify scriptname using hscript.exe?script=<scriptname>" )
qOut( "</BODY></HTML>" )
ELSE
qOut( "Please give .hs name" )
ENDIF
EXIT
ENDIF
// Script not found
IF !file( cScriptName )
IF !empty( GetEnv( "SERVER_NAME" ) )
qqOut( "CONTENT-TYPE: text/html" )
ENDIF
qOut( "<H1>Server Error</H1><P>Script not found: " + cScriptName )
EXIT
ENDIF
// Reads all lines from script -> aHRBHandle
hFile := fOpen( cScriptName, 0 )
cFile := space( IF_BUFFER )
cRes := ""
DO WHILE (nPos := fRead( hFile, @cFile, IF_BUFFER )) > 0
cFile := left( cFile, nPos )
cRes += cFile
cFile := space( IF_BUFFER )
ENDDO
fClose( cFile )
// "Break" infile into lines
nStartPos := 1
FOR i := 1 TO len( cRes )
IF substr( cRes, i, 1 ) == chr(13)
IF i = (nStartPos + 1)
aAdd( aHRSHandle, "" )
ELSE
aAdd( aHRSHandle, strtran( ;
substr( cRes, nStartPos, i - nStartPos ), chr(10), "" ) )
ENDIF
nStartPos := i + 1
ENDIF
NEXT
// Translate script to pure HTML
/* TODO: Add support for lines like "<% something" and "something %>" */
nStartPos := 1
lScriptFlag := .f.
FOR i := 1 TO len( aHRSHandle )
cLine := aHRSHandle[i]
IF !lScriptFlag
nPos := at( "<%", cLine ) // Are we in script?
IF nPos == 0 // No, use qout to
aadd( aResult, "qOut( '" + cLine + "' )" ) // write HTML code
ELSE // Yes.
IF at( "%>", cLine ) != 0 // Is it inline?
aadd( aResult, "qOut( '" + ; // Yes, translate
substr( cLine, 1, nPos-1 ) + ; // only HTML to
"' ) " + NewLine + ; // qOut( <hmtl> )
substr( cLine, nPos + 2, ;
at( "%>", cLine ) - ;
(nPos + 2) ) + ;
NewLine + "qOut( '" + ;
substr( cLine, at( "%>", cLine ) + ;
2 ) + "' )" )
ELSE // No.
lScriptFlag := .t. // Change the flag
aadd( aResult, "" ) // Add blank line
ENDIF
ENDIF
ELSE
IF at( "%>", cLine ) == 0 // Is this line EOS? - End of Script<g>
aadd( aResult, cLine ) // No, add
ELSE // Yes,
lScriptFlag := .f. // Change the flag
aadd( aResult, "" ) // Add blank line
ENDIF
ENDIF
NEXT
// Creates the temporary PRG
cFile := cLocation + cHost + ".prg" // Output file name
hFile := fCreate( cFile )
FOR i := 1 TO len( aResult )
fWrite( hFile, aResult[i] + chr(13)+chr(10) )
NEXT
fClose( hFile )
// Creates the temporary HRB, erases the PRG
__Run( cHarbourDir + "harbour.exe " + cFile + " /q /n /gHRB" )
fErase( cFile )
// Runs using Tugboat
cFile := strtran( upper( cFile ), ".PRG", ".HRB" )
HB_Run( cFile )
// Erases the HRB
fErase( cFile )
// That's all, folks!
EXIT
ENDDO
RETURN( NIL )
FUNCTION ParseString( cString, cDelim, nRet )
LOCAL cBuf, aElem, nPosFim, nSize, i
nSize := len( cString ) - len( StrTran( cString, cDelim, '' ) ) + 1
aElem := array( nSize )
cBuf := cString
i := 1
FOR i := 1 TO nSize
nPosFim := at( cDelim, cBuf )
IF nPosFim > 0
aElem[i] := substr( cBuf, 1, nPosFim - 1 )
ELSE
aElem[i] := cBuf
ENDIF
cBuf := substr( cBuf, nPosFim + 1, len( cBuf ) )
NEXT i
RETURN( aElem[ nRet ] )

View File

@@ -0,0 +1,2 @@
@echo off
call hb32 hscript

View File

@@ -0,0 +1,32 @@
@echo off
IF NOT EXIST hscript.exe GOTO :missing
:start
SET HARBOUR_DIR=\HARBOUR\BIN\
hscript hello.hs >hello.htm
hscript multiply.hs >multiply.htm
hscript dir.hs >dir.htm
cls
echo Ready to go!
echo\
echo If you're under W95/98 try:
echo\
echo start hello.htm
echo -or-
echo start multiply.htm
echo -or-
echo start dir.htm
goto end
:missing
echo Missing hscript.exe
echo\
echo Press any key to build it or Ctrl+C to quit...
pause>nul
call makehs
goto :start
:end

View File

@@ -0,0 +1,49 @@
<%
/*
*
* multiply.hs
* HarbourScript Test
*
*/
FUNCTION Main()
LOCAL i, j
IF !empty( GetEnv( "SERVER_NAME" ) )
qqOut( "HTTP/1.0 200 OK" )
qOut( "CONTENT-TYPE: TEXT/HTML" )
qOut( "" )
ENDIF
%>
<HTML>
<HEAD>
<TITLE>Testing script</TITLE>
</HEAD>
<H1><% qOut( "Teste de HarbourScript!" ) %></H1>
<BODY>
<%
FOR i := 1 TO 10
%>
<TABLE border=1>
<TR>
<%
FOR j := 1 TO 10
%>
<TR>
<TD><% qOut( str( i, 2 ) + " x " + str( j, 2 ) ) %></TD>
<TD><% qOut( i*j ) %></TD>
</TR>
<%
NEXT
%>
</TABLE>
<BR>
<%
NEXT
%>
</BODY>
</HTML>

View File

@@ -0,0 +1,96 @@
WARNING
-------
This document has serious bugs related to English Language.
I take no responsabilities for any misinformation in any form.
<GG>
HarbourScript Alfa Edition
--------------------------
Inside this zip file you will find HarbourScript package. This
should be unzipped to TESTS\WORKING\HSCRIPT directory in order
to work w/o any changes.
To make the HarbourScript Translator, hscript.exe, use MAKEHS.BAT.
If you are going to test offline, there's no need to make it,
it will be done automatically for you (Batch Power<g>). To test it,
you'll have the following options:
Testing HarbourScript using MS-Personal Web Server
--------------------------------------------------
(and maybe IIS 3.0+ too!)
1. Copy hscript.exe and harbour.exe to your cgi-bin directory
(or any other with Scripting allowed)
2. Copy all the scripts that you want to the same directory
3. You can now test Harbour Script using
http://localhost/cgi-bin/hscript?script=<script>.hs
Note: The hscript.exe program still locks the server sometimes.
This is due to external compilation of the resulting code. As
soon as we start to use macro substitution instead, this will
become more stable.
Testing HarbourScript without a Web Server
------------------------------------------
1. Make the sample scripts with MAKEHTM.
2. Browse the resulting .htm files as reported on screen.
How do this thing work?
-----------------------
Well, the HS (HarbourScript) tecnology is based on the ASP
(Active Server Pages) concept and someway in new Oracle 8i's
too.
A .hs page is like any normal HTML page with Special Tags and
Embedded Code. Those tags are: <% (Start Scripting) and %>
(End Scripting). Once you run this script, the HS translator
translates the Embedded Code into true Harbour Code and executes
it. In other words, you write your PRGs INSIDE your web pages.
This concept is called active content.
Known bugs
----------
- Web Server hanging some times (see above);
- No support for <% and %> tags on the same line without its
corresponding tag, eg.:
<% FUNCTION Main()
%><H1><% qOut( "Hello world!" ) %></H1><%
RETURN( NIL )%>
- No support for multiple <% %> tags in the same line, eg.:
...
<TD><% qOut( aArr[1] ) %></TD><TD><% qOut( aArr[2] ) %></TD>
...
Open questions
--------------
Things not working due to lack of knowledge (if you know how
to do any of this things, leave a message on Harbour List with
subject HS Open questions, thanks! ;) ):
- How to associate .hs with hscript.exe safely in PWS and IIS.
I associated it using the Registry Key HKEY_LOCAL_MACHINE\System\>
CurrentControlSet\Services\W3SVC\Parameters\Script Map but
whenever I call the script I get a Server Error 500 without any
further explanation.
Felipe G. Coury
fcoury@flexsys-ci.com