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

  1. ##########################################################
  2. # GDIdb demo script (c) 1997 Global Data Industries
  3. # Datasource=workweb.mdb (Access database)
  4. #
  5. # In this example, SQL queries are made to extract the
  6. # different categories of jobs contained in a single
  7. # database table. Because the jobs in each category are
  8. # the result of a database search, care is needed to define
  9. # SQL search criteria that will accurately sort the data.
  10. # It is always possible that some jobs will not be included
  11. # under any category, and that some jobs will be included
  12. # in several categories.
  13. ##########################################################
  14.  
  15.  
  16.  
  17.  
  18. ##########################################################
  19. # variable catpagecount is used to generate a unique link
  20. # for each of the category pages, and for the pages linked
  21. # under each category. It is incremented once for each
  22. # category produced.
  23.  
  24. &defvar(?catpagecount?)
  25. &assign(?catpagecount?,1)
  26.  
  27.  
  28.  
  29.  
  30. ##########################################################
  31. # Print the information screen
  32.  
  33. &cls
  34. &print("WorkWeb 2 Demo Script")
  35. &print("-----------------------------------")
  36.  
  37.  
  38.  
  39.  
  40. ##########################################################
  41. # declare the ODBC data source
  42.  
  43. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=workweb.mdb")
  44.  
  45.  
  46.  
  47.  
  48. ##########################################################
  49. # call the subroutine that generates the top-level HTML
  50. # index page
  51.  
  52. &indexpage
  53.  
  54.  
  55.  
  56.  
  57. ##########################################################
  58. # Create and fill each of the job categories using &jcat
  59. # subroutine. (Defined later in the script) The first
  60. # argument to the function is used as the category name,
  61. # the second is used in the SQL query to fetch relevant
  62. # job vacancies.
  63.  
  64. # Analogue Engineers
  65. &jcat("Analogue Engineers","Analogue")
  66.  
  67. # Software Engineers
  68. &jcat("Software Engineers","software")
  69.  
  70. # HTML Authors
  71. &jcat("HTML Authors","html")
  72.  
  73. # RF Engineers
  74. &jcat("R.F. Engineers","rf")
  75.  
  76. # Hardware Engineers
  77. &jcat("Hardware Engineers","hardware engineer")
  78.  
  79. # ASIC Engineers
  80. &jcat("ASIC Engineers","asic")
  81.  
  82.  
  83.  
  84.  
  85. ##########################################################
  86. # print the finishing message
  87.  
  88. &msgbox("All done!",iconinformation)
  89. &cls
  90. &print("Demo web site HTML generation complete. Click the Preview HTML button to see the results.")
  91. &print
  92. &print
  93.  
  94. # END OF SCRIPT
  95.  
  96.  
  97.  
  98.  
  99. ##########################################################
  100. # SUBROUTINES
  101.  
  102.  
  103.  
  104.  
  105. ##########################################################
  106. # This is the top-level page containing links to the pages
  107. # created from the database searches. This page is actually
  108. # static (it contains no database data) so could be created
  109. # as a normal HTML file and left on the web server.
  110. # It has been included in this script merely for information.
  111.  
  112. &defsub("indexpage")
  113. {
  114.     &html ("index.html")
  115.     {
  116.         <HTML>
  117.         <HEAD>
  118.         <TITLE>Work Web</TITLE>
  119.         </HEAD>
  120.         <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  121.         <FONT FACE="Verdana,Helvetica">
  122.         <IMG SRC="ww1.gif">
  123.         <BR><BR><BR><BR><BR><BR>
  124.         <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  125.         <TR>
  126.         <TD VALIGN=TOP>
  127.         <FONT FACE="Verdana,Helvetica">
  128.         <FONT SIZE="+2">Select a Job Category:</FONT>
  129.         <BR><BR>
  130.         <UL>
  131.  
  132.         # subroutine jcat will produce all of the files that link
  133.         # to the following links
  134.         
  135.         <LI><A HREF="cat1.html" onMouseover="window.status='View Jobs in category Analogue Engineers';return true">Analogue Engineers</A><BR>
  136.         <LI><A HREF="cat2.html" onMouseover="window.status='View Jobs in category Software Engineers';return true">Software Engineers</A><BR>   
  137.         <LI><A HREF="cat3.html" onMouseover="window.status='View Jobs in category HTML Authors';return true">HTML Authors</A><BR> 
  138.         <LI><A HREF="cat4.html" onMouseover="window.status='View Jobs in category RF Engineers';return true">RF Engineers</A><BR> 
  139.         <LI><A HREF="cat5.html" onMouseover="window.status='View Jobs in category Hardware Engineers';return true">Hardware Engineers</A><BR> 
  140.         <LI><A HREF="cat6.html" onMouseover="window.status='View Jobs in category  ASIC Designers';return true">ASIC Designers</A><BR> 
  141.         </UL>
  142.         </FONT>
  143.         </TD>
  144.         <TD WIDTH="45%" VALIGN=TOP><FONT FACE="Verdana,Helvetica">
  145.         <B>This Site</B> demonstrates the use of GDI's Database
  146.         publishing software. A single database table consisting of
  147.         jobs is grouped into job categories, this is merged with the web site
  148.         HTML and passed to the web server <I>automatically.</I> 
  149.         </FONT>
  150.         </TD>
  151.         </TR>
  152.         </TABLE>
  153.         <BR><BR><BR>
  154.         <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  155.         <TR>
  156.         <TD>
  157.         <FONT FACE="Verdana,Helvetica"> 
  158.         <B>System Bullet points:</B>
  159.         <UL>
  160.         <LI> Totally automated publishing of database and spreadsheet data using a dial-up Internet connection.
  161.         <LI> The database does not need to be stored on the web server.
  162.         <LI> No specialist knowledge is required by web site maintainer.
  163.         <LI> Zero administration overhead- Just set the times/days when you
  164.         want to update your web site from your database and forget it!
  165.         </UL>
  166.         </FONT>
  167.         </TD>
  168.         </TR>
  169.         </TABLE>
  170.         <CENTER>
  171.         <FONT FACE="Helvetica">
  172.         <BR><BR>
  173.         <I>Web site design by:</I><BR>
  174.         <A HREF="http://www.gd-ind.com/">GLOBAL DATA INDUSTRIES</A>
  175.         </FONT>
  176.         </CENTER>
  177.         </FONT>
  178.         </BODY>
  179.         </HTML>
  180.     }
  181. }
  182.  
  183.  
  184.  
  185.  
  186. ##########################################################
  187. # Subroutine jcat handles the creation of the job category
  188. # pages, and is called once for each job category processed.
  189. # The function uses values passed as arguments, these are
  190. # accessed in the subroutine using ?argv? variable array.
  191. # Note the use of nested &html functions in this subroutine,
  192. # where the job content page is generated 1/2 way through
  193. # the generation of the job category page
  194.  
  195. &defsub("jcat")
  196. {
  197.     &html("cat?catpagecount?.html")
  198.     {
  199.         &print("Creating category ?catpagecount?")
  200.         &inc(?catpagecount?)
  201.         <HTML>
  202.         <HEAD>
  203.         <TITLE>Jobs List</TITLE>
  204.         </HEAD>
  205.         <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  206.         <FONT FACE="Verdana,Helvetica">
  207.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  208.         <TR>
  209.         <TD><IMG SRC="wwbullet1.gif"></TD>
  210.         <TD>
  211.         <FONT SIZE="+3" FACE="Verdana,Helvetica">
  212.         ?argv[1]?
  213.         </FONT>
  214.         </TD>
  215.         </TR>
  216.         </TABLE>
  217.         <UL><UL>
  218.  
  219.         # this subroutine uses functions &sql, &if and &foreachrow.
  220.         # A slightly simpler alternative would be to use the &getdata
  221.         # function followed by a &else function.
  222.  
  223.         &sql("SELECT * FROM Jobs WHERE JobDesc Like '%?argv[2]?%'")
  224.         {
  225.            &if (?recordsetsize?==0)
  226.            {
  227.               Sorry! We currently have no jobs in this category.
  228.            }
  229.         
  230.            &foreachrow
  231.            {
  232.               <LI><A HREF="p?catpagecount?n?rownumber?.html" onMouseover="window.status='View Job (?JobTitle?) details.';return true">?JobTitle?</A>
  233.               &html("p?catpagecount?n?rownumber?.html")
  234.               {
  235.                  <HTML>
  236.                  <HEAD>
  237.                  <TITLE>Job Description</TITLE>
  238.                  </HEAD>
  239.                  <BODY BACKGROUND="wwbg1.gif">
  240.                  <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  241.                  <TR>
  242.                  <TD><IMG SRC="wwbullet1.gif"></TD>
  243.                  <TD>
  244.                  <FONT SIZE="+2" FACE="Verdana,Helvetica">
  245.                  ?JobTitle?
  246.                  </FONT>
  247.                  </TD>
  248.                  </TR>
  249.                  </TABLE>
  250.                  <CENTER>
  251.                  <TABLE WIDTH="90%" CELLSPACING=10 BORDER=0>
  252.                  <TR>
  253.                  <TD>
  254.                  <FONT FACE="Verdana,Helvetica" SIZE="+1">Job ref: ?JobNo?</FONT>
  255.                  <TT>
  256.                  <FONT SIZE="+1"><P>?JobDesc?</FONT></TT>
  257.                  </TD>
  258.                  </TR>
  259.                  </TABLE>
  260.                  </CENTER>
  261.                  </BODY>
  262.                  </HTML>
  263.               }
  264.            }
  265.         }
  266.         </UL></UL>
  267.         </FONT>
  268.         </BODY>
  269.         </HTML>
  270.     }
  271. }
  272.