home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / sharewar / gdidbpro / data1.cab / Example_Files / projects / default / workweb3.scp < prev    next >
Text File  |  2000-05-26  |  6KB  |  254 lines

  1. ##########################################################
  2. # GDIdb demo script (c) 1997 Global Data Industries
  3. # Datasource=workweb.mdb (Access database)
  4. #
  5. # If you have a large table of data that you'd like to
  6. # split across several HTML pages, study this script
  7. # for hints on how to do it.
  8. ##########################################################
  9.  
  10.  
  11.  
  12.  
  13. ##########################################################
  14. # Declare & initialise variables used in script
  15.  
  16. &defvar(?var1?,?categorysize?,?pagenum?,?ptot?,?lcount?,?tmp?)
  17. &assign(?pagenum?,1)
  18.  
  19.  
  20.  
  21.  
  22. ##########################################################
  23. # ?categorysize? sets the amount of jobs that are placed
  24. # on each page. try changing the value from 3 to 4 to see
  25. # the effect.
  26.  
  27. &assign(?categorysize?,3)
  28.  
  29.  
  30.  
  31.  
  32. ##########################################################
  33. # Print the script information screen
  34.  
  35. &cls
  36. &print("WorkWeb 3 Demo Script")
  37. &print("------------------------------------")
  38.  
  39.  
  40.  
  41.  
  42. ##########################################################
  43. # Declare the database file.
  44.  
  45. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=workweb.mdb")
  46.  
  47.  
  48.  
  49.  
  50. ##########################################################
  51. # Start generating the HTML
  52.  
  53. &html("index.html")
  54. {
  55.     <HTML>
  56.     <HEAD>
  57.     <TITLE>Work Web</TITLE>
  58.     </HEAD>
  59.     <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  60.     <FONT FACE="Verdana,Helvetica">
  61.     <IMG SRC="ww1.gif">
  62.     <BR><BR><BR><BR><BR><BR>
  63.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  64.     <TR>
  65.     <TD VALIGN=TOP>
  66.     <FONT FACE="Verdana,Helvetica">
  67.  
  68.     # select all of the data in the "jobs" table
  69.     
  70.     &sql("SELECT * FROM Jobs")
  71.     {
  72.         &assign(?ptot?,?recordsetsize?/?categorysize?)
  73.         
  74.         # only create job pages & links if the database
  75.         # actually contains some vacancies!
  76.         
  77.         &if(?recordsetsize?>0)
  78.         {
  79.             <FONT SIZE="+2">Select a link:</FONT>
  80.             <UL><UL>
  81.  
  82.             # repeat this block as long as there is still data
  83.             # to process
  84.             
  85.             &loop(?recordsetsize?>?rownumber?)
  86.             {
  87.                 &assign(?var1?,?rownumber?+?categorysize?-1)
  88.                 <A HREF="content?pagenum?.html">Jobs ?rownumber?-?var1?</A><BR>
  89.  
  90.                 # create a page with ?categorysize? number of
  91.                 # jobs on it (by calling subroutine &datapage)
  92.                 
  93.                 &datapage
  94.             }
  95.  
  96.             </UL></UL>
  97.         }
  98.  
  99.         # if there's no data in the database, print a sorry message
  100.         
  101.         &else
  102.         {
  103.             <FONT SIZE="+2">Sorry!<BR>The database is currently empty.</FONT>
  104.         }
  105.     }
  106.     </FONT>
  107.     </TD>
  108.     <TD WIDTH="45%" VALIGN=TOP><FONT FACE="Verdana,Helvetica">
  109.     <B>This Site</B>  demonstrates the use of GDI's Database
  110.     publishing software. A database consisting of
  111.     a large table of jobs is broken down into manageable
  112.     chunks before being merged with the web site
  113.     HTML and passed to the web server <I>automatically.</I> 
  114.     </FONT>
  115.     </TD>
  116.     </TR>
  117.     </TABLE>
  118.     <BR><BR><BR>
  119.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  120.     <TR>
  121.     <TD>
  122.     <FONT FACE="Verdana,Helvetica"> 
  123.     <B>System Bullet points:</B>
  124.     <UL>
  125.     <LI> Totally automated publishing of database and spreadsheet data using a dial-up Internet connection.
  126.     <LI> The database does not need to be stored on the web server.
  127.     <LI> No specialist knowledge is required by web site maintainer.
  128.     <LI> Zero administration overhead- Just set the times/days when you
  129.     want to update your web site from your database and forget it!
  130.     </UL>
  131.     </FONT>
  132.     </TD>
  133.     </TR>
  134.     </TABLE>
  135.     <CENTER>
  136.     <FONT FACE="Helvetica">
  137.     <BR><BR>
  138.     <I>Web site design by:</I><BR>
  139.     <A HREF="http://www.gd-ind.com/">GLOBAL DATA INDUSTRIES</A>
  140.     </FONT>
  141.     </CENTER>
  142.     </FONT>
  143.     </BODY>
  144.     </HTML>
  145. }
  146.  
  147.  
  148.  
  149.  
  150. ##########################################################
  151. # Print finished message & dialog
  152.  
  153. &msgbox("Script finished!")
  154. &cls
  155. &print("HTML generation complete. Click the Preview HTML button to view the results.")
  156. &print
  157. &print
  158.  
  159. # END OF SCRIPT
  160.  
  161.  
  162.  
  163.  
  164. ##########################################################
  165. # SUBROUTINES
  166.  
  167.  
  168.  
  169.  
  170. ############################################################
  171. # The following subroutine is used to generate the DATA HTML
  172. # pages (The pages linked to the top-level page)
  173.  
  174. &defsub("datapage")
  175. {
  176.     # Print progress message
  177.     
  178.     &print("Processing Jobs ?rownumber?-?var1?")
  179.  
  180.     &html("content?pagenum?.html")
  181.     {
  182.         <HTML>
  183.         <HEAD>
  184.         <TITLE>Jobs ?rownumber?-?var1?</TITLE>
  185.         </HEAD>
  186.         <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  187.         <FONT FACE="Verdana,Helvetica">
  188.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  189.         <TR>
  190.         <TD><IMG SRC="wwbullet1.gif"></TD>
  191.         <TD>
  192.         <FONT SIZE="+3" FACE="Verdana,Helvetica">
  193.         Jobs ?rownumber?-?var1?
  194.         </FONT>
  195.         </TD>
  196.         </TR>
  197.         </TABLE>
  198.         <UL><UL>
  199.         <BR>
  200.  
  201.         # print out the job details, the max. number of jobs
  202.         # that will be put on each page is set by ?categorysize?
  203.         
  204.         &foreachrow(?categorysize?)
  205.         {
  206.             <B>?JobTitle?</B>
  207.             <BR>
  208.             <TT>?JobDesc?</TT>
  209.             <BR><BR><BR>
  210.         }
  211.  
  212.         # this bit of script code adds the links to pages 1,2,3 etc
  213.  
  214.         &repeat(?lcount?,?ptot?+0.5)
  215.         {
  216.             # the current page number is printed in red & is not a link
  217.  
  218.             &if(?pagenum?==?lcount?)
  219.             {
  220.                 <FONT COLOR="Red">?lcount?</FONT>
  221.             }
  222.             &else
  223.             {
  224.                 # all other pages are printed as links
  225.                 
  226.                 <A HREF="content?lcount?.html">?lcount?</A>
  227.             }
  228.         }
  229.         
  230.         # this bit of script adds previous/next links. it's conditional,
  231.         # they are only added if there actually are previous/next pages.
  232.         
  233.         &if(?pagenum?!=1)
  234.         {
  235.             &assign(?tmp?,?pagenum?-1)
  236.             <A HREF="content?tmp?.html">Previous</A>
  237.         }
  238.         &if(?pagenum?<?ptot?)
  239.         {
  240.             &assign(?tmp?,?pagenum?+1)
  241.             <A HREF="content?tmp?.html">Next</A>
  242.         }
  243.         </UL></UL>
  244.         </FONT>
  245.         </BODY>
  246.         </HTML>
  247.         
  248.         # this variable is used as the page count, and is incremented
  249.         # after each page.
  250.         
  251.         &inc(?pagenum?)
  252.     }
  253. }
  254.