Files
harbour-core/contrib/hbtip/tests/dbtohtml.prg
Viktor Szakats 1938dd0a70 2017-04-14 13:22 UTC+0200 Aleksander Czajczynski (hb fki.pl)
* contrib/hbtip/ccgi.prg
  * contrib/hbtip/client.prg
  * contrib/hbtip/encb64.prg
  * contrib/hbtip/encoder.prg
  * contrib/hbtip/encqp.prg
  * contrib/hbtip/encurl.prg
  * contrib/hbtip/ftpcli.prg
  * contrib/hbtip/hbtip.hbp
  * contrib/hbtip/hbtip.hbx
  * contrib/hbtip/httpcli.prg
  * contrib/hbtip/log.prg
  * contrib/hbtip/mail.prg
  * contrib/hbtip/mime.c
  * contrib/hbtip/misc.c
  * contrib/hbtip/popcli.prg
  * contrib/hbtip/sessid.prg
  * contrib/hbtip/smtpcli.prg
  * contrib/hbtip/thtml.ch
  * contrib/hbtip/thtml.prg
  * contrib/hbtip/tip.ch
  * contrib/hbtip/url.prg
  + contrib/hbtip/base64u.prg
  + contrib/hbtip/mailassy.prg
  * contrib/hbtip/sendmail.prg -> [...]/mailsend.prg
  + contrib/hbtip/WARNING.txt
  * contrib/hbtip/tests/base64.prg
  * contrib/hbtip/tests/dbtohtml.prg
  * contrib/hbtip/tests/dnldftp.prg -> [...]/ftp_dl.prg
  * contrib/hbtip/tests/ftpadv.prg -> [...]/ftp_adv.prg
  + contrib/hbtip/tests/email.prg
  + contrib/hbtip/tests/ftp_ul.prg
  - contrib/hbtip/tests/gmail.hbp
  - contrib/hbtip/tests/gmail.prg
  * contrib/hbtip/tests/hbmk.hbm
  * contrib/hbtip/tests/httpadv.prg -> [...]/http_adv.prg
  * contrib/hbtip/tests/httpcli.prg -> [...]/http_cli.prg
  + contrib/hbtip/tests/http_qry.prg
  - contrib/hbtip/tests/loadhtml.prg
  + contrib/hbtip/tests/test.prg
  + contrib/hbtip/tests/url.prg
    * synced with 3.4 fork by Viktor Szakats
    ; the only difference is slightly edited WARNING.txt

  - contrib/hbtip/credent.prg
    % deleted TIPCredentials() class that was never implemented

  ; changes above come from vast number of commits in 3.4 repository - many
    thanks to Viktor Szakats for maintaining
2017-04-14 13:22:09 +02:00

109 lines
2.7 KiB
Plaintext

/* Demonstrating operator overloading for creating an HTML document */
#require "hbtip"
#require "hbtest"
PROCEDURE Main()
LOCAL oDoc, oNode, oTable, oRow, oCell
LOCAL i, j
IF ! hbtest_Table()
? "Error: Test database couldn't be created"
RETURN
ENDIF
oDoc := THtmlDocument():New()
/* Operator "+" creates a new node */
oNode := oDoc:head + "meta"
oNode:name := "Generator"
oNode:content := "THtmlDocument"
/* Operator ":" returns first "h1" from body (creates if not existent) */
oNode := oDoc:body:h1
oNode:text := "My address book"
/* Operator "+" creates a new <p> node */
oNode := oDoc:body + "p"
/* Operator "+" creates a new <font> node with attribute */
oNode := oNode + 'font size="5"'
oNode:text := "This is a "
/* Operator "+" creates a new <b> node */
oNode := oNode + "b"
/* Operator "+" creates a new <font> node with attribute */
oNode := oNode + 'font color="blue"'
oNode:text := "sample "
/* Operator "-" closes 2nd <font>, result is <b> node */
oNode := oNode - "font"
/* Operator "-" closes <b> node, result is 1st <font> node */
oNode := oNode - "b"
oNode:text := "database!"
/* Operator "-" closes 1st <font> node, result is <p> node */
oNode := oNode - "font"
oNode := oNode + "hr"
HB_SYMBOL_UNUSED( oNode )
/* Operator ":" returns first "table" from body (creates if not existent) */
oTable := oDoc:body:table
oTable:attr := 'border="0" width="100%" cellspacing="0" cellpadding="0"'
oRow := oTable + 'tr bgcolor="lightcyan"'
FOR i := 1 TO FCount()
oCell := oRow + "th"
oCell:text := FieldName( i )
oCell := oCell - "th"
HB_SYMBOL_UNUSED( oCell )
NEXT
oRow := oRow - "tr"
HB_SYMBOL_UNUSED( oRow )
FOR i := 1 TO 10
oRow := oTable + "tr"
oRow:bgColor := iif( RecNo() % 2 == 0, "lightgrey", "white" )
FOR j := 1 TO FCount()
oCell := oRow + "td"
oCell:text := FieldGet( j )
oCell := oCell - "td"
HB_SYMBOL_UNUSED( oCell )
NEXT
oRow := oRow - "tr"
HB_SYMBOL_UNUSED( oRow )
dbSkip()
NEXT
oNode := oDoc:body + "hr"
HB_SYMBOL_UNUSED( oNode )
oNode := oDoc:body + "p"
oNode:text := "10 records from database " + Alias()
dbCloseArea()
IF oDoc:writeFile( "address.html" )
? "File created:", "address.html"
ELSE
? "Error:", FError()
ENDIF
WAIT
? tip_HtmlToStr( oDoc:body:getText() )
hb_run( "address.html" )
hb_vfErase( "address.html" )
RETURN