home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / database / ezacce / players.bas < prev    next >
BASIC Source File  |  1995-02-27  |  8KB  |  272 lines

  1. global dbf___Players as database
  2. global Playersdbf___ as table
  3. global eof_Players as integer
  4. global Playerslastindex as string
  5. global PlayersDBFOPEN as INTEGER
  6. global LName as string *  15
  7. global FName as string *  15
  8. global Initial as string *  1
  9. global Birthdate as string *  8 
  10. global SeqNum as string *  4
  11. global LNamekeycount as integer
  12. global LNameLENGTHOFLASTKEY as integer
  13. global SeqNumkeycount as integer
  14. global SeqNumLENGTHOFLASTKEY as integer
  15. sub open_Players ()
  16.  
  17.     set dbf___Players = opendatabase("c:\ez\sample\LITTLELG.mdb", false, false, "")
  18.     set Playersdbf___ = dbf___Players.opentable("Players")
  19.  
  20. end sub
  21. sub RP_Players ()
  22.  
  23.     IF NOT PlayersDBFOPEN THEN
  24.          OPEN_Players
  25.          PlayersDBFOPEN = TRUE
  26.     END IF
  27.     IF PlayersDBF___.EOF AND PlayersDBF___.BOF THEN
  28.          EOF_Players=TRUE
  29.          INIT_Players
  30.     ELSE
  31.          if Playerslastindex <> "PHYSICAL" then
  32.               Playersdbf___.index = ""
  33.               Playerslastindex = "PHYSICAL"
  34.               Playersdbf___.movefirst
  35.          else
  36.               Playersdbf___.movenext
  37.          end if
  38.          if Playersdbf___.eof then
  39.               eof_Players = true
  40.               INIT_Players
  41.          Playerslastindex = ""
  42.          else
  43.               tomem_Players
  44.               eof_Players = false
  45.          end if
  46.     end if
  47.  
  48. end sub
  49. sub re_LName ()
  50.  
  51.     IF NOT PlayersDBFOPEN THEN
  52.          OPEN_Players
  53.          PlayersDBFOPEN = TRUE
  54.     END IF
  55.     if Playerslastindex <> "LName" then
  56.          Playersdbf___.index = "LName"
  57.          Playerslastindex = "LName"
  58.          LNamekeycount=  3
  59.          LNameLENGTHOFLASTKEY = LEN(RTRIM$(Initial))
  60.          if Initial = space$(len(Initial)) OR ASC(Initial) = 0 then 
  61.               LNamekeycount =  2
  62.               LNameLENGTHOFLASTKEY = LEN(RTRIM$(FName))
  63.          END IF
  64.          if FName = space$(len(FName)) OR ASC(FName) = 0 then 
  65.               LNamekeycount =  1
  66.               LNameLENGTHOFLASTKEY = LEN(RTRIM$(LName))
  67.          END IF
  68.          if LName = space$(len(LName)) OR ASC(LName) = 0 then 
  69.               LNamekeycount =  0
  70.          END IF
  71.          eof_Players = false
  72.          Playersdbf___.seek ">=", LName, FName, Initial
  73.          if Playersdbf___.nomatch then eof_Players = true
  74.     else
  75.          Playersdbf___.movenext
  76.          if Playersdbf___.eof then eof_Players = true
  77.     end if
  78.     if not eof_Players then
  79.          If LNamekeycount >  0 then
  80.               if LNamekeycount >  1 then
  81.                    if LName <> Playersdbf___("LName")  then eof_Players = true
  82.               else
  83.                    if LEFT$(LName,LNameLENGTHOFLASTKEY) <> LEFT$(Playersdbf___("LName"),LNameLENGTHOFLASTKEY) then eof_Players = true
  84.               end if
  85.          end if
  86.     end if
  87.     if not eof_Players then
  88.          If LNamekeycount >  1 then
  89.               if LNamekeycount >  2 then
  90.                    if FName <> Playersdbf___("FName")  then eof_Players = true
  91.               else
  92.                    if LEFT$(FName,LNameLENGTHOFLASTKEY) <> LEFT$(Playersdbf___("FName"),LNameLENGTHOFLASTKEY) then eof_Players = true
  93.               end if
  94.          end if
  95.     end if
  96.     if not eof_Players then
  97.          If LNamekeycount >  2 then
  98.               if LNamekeycount >  3 then
  99.                    if Initial <> Playersdbf___("Initial")  then eof_Players = true
  100.               else
  101.                    if LEFT$(Initial,LNameLENGTHOFLASTKEY) <> LEFT$(Playersdbf___("Initial"),LNameLENGTHOFLASTKEY) then eof_Players = true
  102.               end if
  103.          end if
  104.     end if
  105.     if eof_Players then
  106.          Playerslastindex = ""
  107.     else
  108.          tomem_Players
  109.          eof_Players = false
  110.     end if
  111.  
  112. end sub
  113. sub re_SeqNum ()
  114.  
  115.     IF NOT PlayersDBFOPEN THEN
  116.          OPEN_Players
  117.          PlayersDBFOPEN = TRUE
  118.     END IF
  119.     if Playerslastindex <> "SeqNum" then
  120.          Playersdbf___.index = "SeqNum"
  121.          Playerslastindex = "SeqNum"
  122.          SeqNumkeycount=  1
  123.          SeqNumLENGTHOFLASTKEY = LEN(RTRIM$(SeqNum))
  124.          if SeqNum = space$(len(SeqNum)) OR ASC(SeqNum) = 0 then 
  125.               SeqNumkeycount =  0
  126.          END IF
  127.          eof_Players = false
  128.          Playersdbf___.seek ">=", SeqNum
  129.          if Playersdbf___.nomatch then eof_Players = true
  130.     else
  131.          Playersdbf___.movenext
  132.          if Playersdbf___.eof then eof_Players = true
  133.     end if
  134.     if not eof_Players then
  135.          If SeqNumkeycount >  0 then
  136.               if SeqNumkeycount >  1 then
  137.                    if SeqNum <> Playersdbf___("SeqNum")  then eof_Players = true
  138.               else
  139.                    if LEFT$(SeqNum,SeqNumLENGTHOFLASTKEY) <> LEFT$(Playersdbf___("SeqNum"),SeqNumLENGTHOFLASTKEY) then eof_Players = true
  140.               end if
  141.          end if
  142.     end if
  143.     if eof_Players then
  144.          Playerslastindex = ""
  145.     else
  146.          tomem_Players
  147.          eof_Players = false
  148.     end if
  149.  
  150. end sub
  151. sub rK_LName ()
  152.  
  153.     IF NOT PlayersDBFOPEN THEN
  154.          OPEN_Players
  155.          PlayersDBFOPEN = TRUE
  156.     END IF
  157.     if Playerslastindex <> "LName" then
  158.          Playersdbf___.index = "LName"
  159.          Playerslastindex = ""
  160.     END IF
  161.     Playersdbf___.seek "=", LName, FName, Initial
  162.     if Playersdbf___.nomatch then 
  163.          eof_Players = true
  164.          Playerslastindex = ""
  165.     else
  166.          tomem_Players
  167.          eof_Players = false
  168.     end if
  169.  
  170. end sub
  171. sub rK_SeqNum ()
  172.  
  173.     IF NOT PlayersDBFOPEN THEN
  174.          OPEN_Players
  175.          PlayersDBFOPEN = TRUE
  176.     END IF
  177.     if Playerslastindex <> "SeqNum" then
  178.          Playersdbf___.index = "SeqNum"
  179.          Playerslastindex = ""
  180.     END IF
  181.     Playersdbf___.seek "=", SeqNum
  182.     if Playersdbf___.nomatch then 
  183.          eof_Players = true
  184.          Playerslastindex = ""
  185.     else
  186.          tomem_Players
  187.          eof_Players = false
  188.     end if
  189.  
  190. end sub
  191. sub tomem_Players ()
  192.  
  193.     IF ISNULL(Playersdbf___("LName")) THEN
  194.          LName = SPACE$(LEN(LName))
  195.     ELSE
  196.          LName = Playersdbf___("LName")
  197.     ENDIF
  198.     IF ISNULL(Playersdbf___("FName")) THEN
  199.          FName = SPACE$(LEN(FName))
  200.     ELSE
  201.          FName = Playersdbf___("FName")
  202.     ENDIF
  203.     IF ISNULL(Playersdbf___("Initial")) THEN
  204.          Initial = SPACE$(LEN(Initial))
  205.     ELSE
  206.          Initial = Playersdbf___("Initial")
  207.     ENDIF
  208.     IF ISNULL(Playersdbf___("Birthdate")) THEN
  209.          Birthdate = "        "
  210.     ELSE
  211.          Birthdate = Playersdbf___("Birthdate")
  212.     ENDIF
  213.     IF ISNULL(Playersdbf___("SeqNum")) THEN
  214.          SeqNum = SPACE$(LEN(SeqNum))
  215.     ELSE
  216.          SeqNum = Playersdbf___("SeqNum")
  217.     ENDIF
  218.  
  219. end sub
  220. sub FROMMEM_Players ()
  221.  
  222.     Playersdbf___("LName") = LName
  223.     Playersdbf___("FName") = FName
  224.     Playersdbf___("Initial") = Initial
  225.     Playersdbf___("Birthdate") = Birthdate
  226.     Playersdbf___("SeqNum") = SeqNum
  227.  
  228. end sub
  229. sub INIT_Players ()
  230.  
  231.     LName = ""
  232.     FName = ""
  233.     Initial = ""
  234.     Birthdate = "        "
  235.     SeqNum = ""
  236.  
  237. end sub
  238. sub close_Players ()
  239.  
  240.     If Playersdbfopen then
  241.          Playersdbf___.close
  242.     end if
  243.  
  244. end sub
  245. sub update_Players ()
  246.  
  247.     IF NOT PlayersDBFOPEN THEN
  248.          OPEN_Players
  249.          PlayersDBFOPEN = TRUE
  250.     END IF
  251.     Playersdbf___.edit
  252.     frommem_Players
  253.     Playersdbf___.update
  254.  
  255. end sub
  256. sub write_Players ()
  257.  
  258.     IF NOT PlayersDBFOPEN THEN
  259.          OPEN_Players
  260.          PlayersDBFOPEN = TRUE
  261.     END IF
  262.     Playersdbf___.addnew
  263.     frommem_Players
  264.     Playersdbf___.update
  265.  
  266. end sub
  267. Sub delete_Players ()
  268.  
  269.     Playersdbf___.delete
  270.  
  271. end sub
  272.