Instruction
Installation
HtmlLib
Programming
Download
Register

HtmlLib --- Html Function Library for FoxPro


Public htmlout,htmlfcolor,htmlbcolor,htmlpos,htmlsize,htmltype
Public htmlclientip,htmlquery,htmlerror,htmlparlen,htmlname
Public htmlpath,htmlpic,htmlin(250,2)

FUNCTION HtmlBegin
Set udfparams to reference
On error do errhand with error( ), message( ), message(1), program( ), lineno( )
htmlpic=""
htmlout=""
htmlfcolor="000000"
htmlbcolor="FFFFFF"
htmlpos="left"
htmlsize="+0"
htmltype="z"
htmlout='Content-type: text/html'+chr(10)+chr(10)
htmlout=htmlout+'<HTML><HEAD>'+chr(10)
htmlout=htmlout+'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">'+chr(10)
htmlout=htmlout+'<META NAME="Author" CONTENT="Lingsong He">'+chr(10)
htmlout=htmlout+'<META NAME="GENERATOR" CONTENT="FoxCgi 1.0">'+chr(10)

PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
htmlerror=htmlerror+'Error number: '+LTRIM(STR(merror))+chr(10)
htmlerror=htmlerror+'Error message: '+mess++chr(10)
htmlerror=htmlerror+'Line of code with error: '+mess1+chr(10)
htmlerror=htmlerror+'Line number of error: '+LTRIM(STR(mlineno))+chr(10)
htmlerror=htmlerror+'Program with error: '+mprog+chr(10)

FUNCTION HtmlTitle
PARAMETERS title
htmlout=htmlout+'<TITLE>'+m.title+'</TITLE>'+chr(10)
htmlout=htmlout+'</HEAD><BODY bgcolor="'+htmlbcolor+'" '
if len(htmlpic)>4
   htmlout=htmlout+'BACKGROUND="'+htmlpic
endif
htmlout=htmlout+'" >'+chr(10)
htmlout=htmlout+'"<br>'+chr(10)

FUNCTION HtmlEnd
htmlout=htmlout+'</BODY></HTML>'+CHR(10)

FUNCTION HtmlLine
htmlout=htmlout+'<hr>'+chr(10)

FUNCTION HtmlReturn
htmlout=htmlout+'<BR>'+chr(10)

FUNCTION HtmlBkImage
PARAMETERS pic
htmlpic=m.pic

FUNCTION HtmlInsertFile
PARAMETERS name
errfile=FOPEN(m.name)
if errfile=-1
  =HtmlSentence("Can not open file !")
  return
endif
ifp_size=FSEEK(errfile,0,2)
=FSEEK(errfile,0,0)
l_string=FREAD(errfile,ifp_size)
=FCLOSE(errfile)
=HtmlParagraph(l_string)

FUNCTION HtmlArrayTable
PARAMETERS aa,n,m
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+'<TABLE BORDER=1>'
FOR I=1 TO N
htmlout=htmlout+'<TR>'
  FOR j=1 TO M
    htmlout=htmlout+'<TH>'+aa(i,j)+'</TH>'
  ENDFOR
htmlout=htmlout+'</TR>'
ENDFOR
htmlout=htmlout+'</TABLE>'
htmlout=htmlout+'</font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlDbfTable
ERASE htmlpath+"txt\temp.txt"
m.name=alias()
if empty(m.name)
  =HtmlSentence("No open dbf !")
  return
endif
m.n=FCOUNT()
m.m=RECCOUNT( )
COPY TO htmlpath+"txt\temp.txt" TYPE DELIMITED with tab
IF (m.m+m.n)=0
  =HtmlSentence("dbf file is empty !")
  return
ENDIF
errfile=FOPEN(htmlpath+"\txt\temp.txt")
if errfile=-1
  =HtmlSentence("Can not open file !")
  return
endif
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+'<TABLE BORDER=1>'
m.str2=chr(9)
FOR m.i=1 to m.m
  m.str=FGETS(errfile,1024)
  m.l=len(str)
  htmlout=htmlout+'<TR>'
  FOR m.j=1 to m.n-1
     m.b=AT(m.str2,m.str)
     m.str1=LEFT(m.str,m.b-1)
     m.str=RIGHT(m.str,m.l-m.b)
     m.l=m.l-m.b
     m.str1=STRTRAN(m.str1,'"', ' ')
     m.str1=alltrim(m.str1)
     IF LEN(m.str1)=0
        m.str1='.'
     ENDIF
     htmlout=htmlout+'<TH>'+m.str1+'</TH>'
  ENDFOR
  m.str=STRTRAN(m.str,'"', ' ')
  m.str=alltrim(m.str)
  IF LEN(m.str)=0
    m.str='.'
  ENDIF
  htmlout=htmlout+'<TH>'+m.str+'</TH></TR>'
ENDFOR
=FCLOSE(errfile)
htmlout=htmlout+'</TABLE>'
htmlout=htmlout+'</font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlLinkGraph
PARAMETERS pic,link
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<A HREF="'+m.link+'">'
htmlout=htmlout+'<IMG SRC="'+m.pic+'"></A>'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlGraph
PARAMETERS pic
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<IMG SRC="'+m.pic+'">'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlLinkSentence
PARAMETERS word,link
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+'<A HREF="'+m.link+'">'
htmlout=htmlout+m.word+'</A></font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'
htmlout=htmlout+'<br>'+chr(10)

FUNCTION HtmlLinkWords
PARAMETERS word,link
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+'<A HREF="'+m.link+'">'
htmlout=htmlout+m.word+'</A></font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlParagraph
PARAMETERS word
htmlout=htmlout+'<pre>'
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+m.word+'</font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'
htmlout=htmlout+'</pre>'+chr(10)

FUNCTION HtmlWords
PARAMETERS word
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+m.word+'</font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'+chr(10)

FUNCTION HtmlSentence
PARAMETERS word
htmlout=htmlout+'<'+htmlpos+'>'
htmlout=htmlout+'<'+htmltype+'>'
htmlout=htmlout+'<font color="'+htmlfcolor+'">'
htmlout=htmlout+'<font size="'+htmlsize+'">'
htmlout=htmlout+m.word+'</font>'
htmlout=htmlout+'</'+htmltype+'>'
htmlout=htmlout+'</'+htmlpos+'>'
htmlout=htmlout+'<br>'+chr(10)

FUNCTION HtmlFontType
PARAMETERS pos
m.pos=upper(m.pos)
IF m.pos="NORMAL"
  htmltype="z"
ENDIF
IF m.pos="BOLD"
  htmltype="B"
ENDIF
IF m.pos="ITALIC"
  htmltype="I"
ENDIF
IF m.pos="UNDERLINE"
  htmltype="U"
ENDIF

FUNCTION Htmlalign
PARAMETERS pos
m.pos=upper(m.pos)
IF m.pos="LEFT"
  htmlpos="left"
ENDIF
IF m.pos="RIGHT"
  htmlpos="right"
ENDIF
IF m.pos="CENTER"
  htmlpos="center"
ENDIF

FUNCTION Htmlhtmlfcolor
PARAMETERS c
m.c=upper(m.c)
IF m.c="WHITE"
  htmlfcolor="#FFFFFF"
ENDIF
IF m.c="GREY"
  htmlfcolor="#C0C0C0"
ENDIF
IF m.c="BLACK"
  htmlfcolor="#000000"
ENDIF
IF m.c="LIGHTRED"
  htmlfcolor="#FF0000"
ENDIF
IF m.c="RED"
  htmlfcolor="#800000"
ENDIF
IF m.c="LIGHTGREEN"
  htmlfcolor="#00FF00"
ENDIF
IF m.c="GREEN"
  htmlfcolor="#008000"
ENDIF
IF m.c="LIGHTBLUE"
  htmlfcolor="#0000FF"
ENDIF
IF m.c="BLUE"
  htmlfcolor="#000080"
ENDIF
IF m.c="LIGHTYELLOW"
  htmlfcolor="#FFFF00"
ENDIF
IF m.c="YELOW"
  htmlfcolor="#808000"
ENDIF
IF m.c="LIGHTCAYN"
  htmlfcolor="#00FFFF"
ENDIF
IF m.c="CAYN"
  htmlfcolor="#008080"
ENDIF

FUNCTION Htmlhtmlbcolor
PARAMETERS c
m.c=upper(m.c)
IF m.c="WHITE"
  htmlbcolor="#FFFFFF"
ENDIF
IF m.c="GREY"
  htmlbcolor="#C0C0C0"
ENDIF
IF m.c="BLACK"
  htmlbcolor="#000000"
ENDIF
IF m.c="LIGHTRED"
  htmlbcolor="#FF0000"
ENDIF
IF m.c="RED"
  htmlbcolor="#800000"
ENDIF
IF m.c="LIGHTGREEN"
  htmlbcolor="#00FF00"
ENDIF
IF m.c="GREEN"
  htmlbcolor="#008000"
ENDIF
IF m.c="LIGHTBLUE"
  htmlbcolor="#0000FF"
ENDIF
IF m.c="BLUE"
  htmlbcolor="#000080"
ENDIF
IF m.c="LIGHTYELLOW"
  htmlbcolor="#FFFF00"
ENDIF
IF m.c="YELOW"
  htmlbcolor="#808000"
ENDIF
IF m.c="LIGHTCAYN"
  htmlbcolor="#00FFFF"
ENDIF
IF m.c="CAYN"
  htmlbcolor="#008080"
ENDIF

FUNCTION HtmlFontSize
PARAMETERS hsize
IF m.hsize="8"
  htmlsize="-2"
ENDIF
IF m.hsize="10"
  htmlsize="-1"
ENDIF
IF m.hsize="12"
  htmlsize="+0"
ENDIF
IF m.hsize="14"
  htmlsize="+1"
ENDIF
IF m.hsize="18"
  htmlsize="+2"
ENDIF
IF m.hsize="24"
  htmlsize="+3"
ENDIF
IF m.hsize="36"
  htmlsize="+4"
ENDIF


Return to main