FirstBase Software, Database Solutions for the Internet



modify_comp.m




# @(#)modify_comp.m	1.1 01/04/99 firstbase.com
#
#
# modify_comp.m - Copyright by FirstBase Software
#
# This code works with dbmacro, a part of the FirstBase database package.
# For more information, see http://www.firstbase.com
#
# standalone modify_comp.m
#
# Tweak an exising record --- RECNO is the one to edit
#

main()
   {
      load(path_dir + "../macro/library.m")
      load(path_dir + "../macro/verify_comp.m")
      comments()
      count_errors = 0
      print(html_open("FirstBase Software: Modify Computer Record"))
      wheader("Modify Computer Record")
      init_computer()
      rec = ston(RECNO)
      if (rec <= 0 | rec > reccnt(cb))
         werror("RECNO for computer dbase out of range in modify_comp.m: "
            + RECNO)
      getrec(rec, cb)

      if (LOCKSTAMP != cbase[LockStamp])
         failure_computer("Lock TimeStamps of request/record do not match", 1)

      inventory = cbase[Inventory]
      
      if (Submit != "Exit"){
         verify_comp()
         }   

      today = cdbdate(now())
      if (count_errors == 0){
         #
         # lock the record to be changed
         #
         st = lock(rec, cb, 0)
         if (st != AOK)
            failure_computer("could not get lock for computer record " +
               RECNO, 1)

         time = now()
         cbase[LockStamp] = ""
         cbase[LockTime] = ""

         if (Submit != "Exit"){
            cbase[ModTime] = date(time)
            cbase[EnterDate] = enterdate
            cbase[BrandName] = brandname
            cbase[ModelName] = modelname
            cbase[CPUSerNo] = cpuserno
            cbase[Options] = options
            cbase[MachType] = machtype
            cbase[MachName] = machname
            cbase[Project] = project
            cbase[ModTime] = IP_TIME
            cbase[ModIP] = IP
            }

         #
         # lock the header so no-one is changing anything.
         #
         st = lock(0, cb, 1)

         #
         # write the record out
         #
         if (st == AOK)
            st = putrec(rec, cb)

         #
         # unlock the header and the record, both
         #
         unlock(0, cb)
         unlock(rec, cb)

         if (st == ERROR)
            failure_computer("putrec failed for computer database recno " +
               RECNO, 1)
         }
      else
         st = ERROR

      inventory = cbase[Inventory]
      brandname = cbase[BrandName]
      print(html_p_open())
      if (st == AOK && Submit != "Exit"){
         printf("Inventory %s (%s): modifications saved.\n",
            inventory, brandname)
         }
      else
         printf("Inventory ``%s'' (brand name ``%s'') NOT modified\n.",
            inventory, brandname)
      print(html_br())
      wfooter("/admin/a_computer.html")
      print(html_close())
      end_computer()
   }




Return to HMS

FirstBase (R) Home Page FirstBase (R) Product Line FirstBase (R) Services FirstBase (R) Company Information Contact Search

© Copyright 1996-2000 FirstBase Software, Inc.