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

  1. ##########################################################
  2. # GDIdb demo script (c) 1998 Global Data Industries
  3. #
  4. # This script demonstrates how to group database records
  5. # alphabetically. A program loop is used to loop through
  6. # each letter in the alphabet, for each letter a recordset
  7. # is generated consisting of all the CD's whose names
  8. # start with that letter.
  9. #
  10. ##########################################################
  11.  
  12.  
  13.  
  14. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=rreview.mdb")
  15.  
  16.  
  17.  
  18. &defvar(?char?,?charl?,?count?)
  19.  
  20.  
  21.  
  22.  
  23. ##########################################################
  24. # the top-level document
  25.  
  26. &html("index.html")
  27. {
  28.     <HTML>
  29.     <HEAD>
  30.     <TITLE>Rave CD's</TITLE>
  31.     </HEAD>
  32.     <BODY BACKGROUND="house.jpg" TEXT="\#AA00D5">
  33.     <IMG SRC="rreview1.gif">
  34.     <BR><BR><BR><BR><BR>
  35.     <CENTER><H4>
  36.     Soul<BR>
  37.     Acid Jazz<BR>
  38.     Hip-Hop<BR>
  39.     Tribal/Deep house<BR>
  40.     Garage/Happy House<BR>
  41.     </H4>
  42.     <H1>\<==============Rave<BR>
  43.     </H1>
  44.     # loop through each letter in the alphabet
  45.     <H2>
  46.     &for(?count?,65,?count?<91,1)
  47.     {
  48.         # convert number to ASCII character
  49.         &chr(?char?,?count?)
  50.         &tolower(?charl?,"?char?")
  51.         &print("Processing the letter ?char?")
  52.         &rec
  53.     }
  54.     </H2>
  55.     <H1>CD's==============\></H1><BR>
  56.     <H4>
  57.     Techno/Nu Energy<BR>
  58.     Hardcore/Jungle<BR>
  59.     Hard House<BR>
  60.     Trance<BR>
  61.     Goa<BR>
  62.     </H4>
  63.     </CENTER>
  64.     <BR><BR><BR><BR><BR>\ 
  65.     </BODY>
  66.     </HTML>
  67. }
  68.  
  69.  
  70.  
  71.  
  72. ##########################################################
  73. # this sub retrieves the recordset which consists of record
  74. # names starting with the current letter. If the recordset
  75. # is not empty, a page is created listing all records
  76. # starting with this letter and the current letter is included
  77. # on the top-level page as a hyperlink. If the recordset
  78. # is empty, the letter is added to the page, but not as a link.
  79.  
  80. &defsub("rec")
  81. {
  82.     # The query looks for text beginning with upper OR lower case letter
  83.     &sql("SELECT * FROM RecordNames WHERE ((RecordName LIKE '?char?%') OR  (RecordName LIKE '?charl?%')) ORDER BY RecordName")
  84.     {
  85.         # only add a link (& a page to link to) if there are CD's under this letter
  86.         &if(?recordsetsize?>0)
  87.         {
  88.             <A HREF="records?char?.html"><B>?char?</B></A>
  89.             &catpage
  90.         }
  91.         &else
  92.         {
  93.             ?char?
  94.         }
  95.     }
  96. }
  97.  
  98.  
  99.  
  100.  
  101. ##########################################################
  102. # In the case that the recordset produced above is not
  103. # empty, this subroutine is called to produce the page
  104. # listing all records starting with the current letter.
  105.  
  106. &defsub("catpage")
  107. {
  108.     &html("records?char?.html")
  109.     {
  110.         <HTML>
  111.         <HEAD>
  112.         <TITLE>Records under the letter ?char?</TITLE>
  113.         </HEAD>
  114.         <BODY BACKGROUND="house.jpg" TEXT="\#AA00D5">
  115.         <TABLE CELLPADDING="5" BGCOLOR=WHITE>
  116.         <TR><TD ALIGN=CENTER BGCOLOR="\#361F72">
  117.         <H1><TT><FONT COLOR=WHITE>==?char?==</FONT></TT></FONT></H1>
  118.         </TD></TR>
  119.         </TABLE>
  120.         <IMG SRC="rreview2.gif" ALIGN=RIGHT>
  121.         <BR><BR>
  122.         <H3>We've the following records under the letter ?char?</H3><BR><BR>
  123.         <UL>
  124.         &foreachrow
  125.         {
  126.             <LI><B>?RecordName?<B>
  127.         }
  128.         </UL>
  129.         </BODY>
  130.         </HTML>
  131.     }
  132. }
  133.