⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plb_dbas.tpl

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 TPL
📖 第 1 页 / 共 2 页
字号:
      te%=92+c%
      val%=count
      exp%=d%-1
      test:
      d%=d%-1
      c%=c%+1
  ENDWH
 close
trap close
trap close


	REM print"complete"
	REM print "print press a key to text opl32 specific dbase code"
	REM get
mod:
endp

proc mod:
  global exp%,val%,te%,te$(32)
  global path$(32),val$(2),exp$(2)
  local c%,d%,b%(40),e%

  path$=KPath$
  REM cls
  REM print"testing DBASE: modify, insert, put, cancel + bookmarks"
  REM print datim$

  trap delete path$+"modify.dbf"


  create path$+"modify.dbf",A, POS$, i%
  close
  create path$+"modify.dbf FIELDS name , age , height TO Table2",B,n$,a%,h%
  close
  create path$+"modify.dbf FIELDS name , age , height TO Table3",c,n$,a%,h%
  close

  Open path$+"modify.dbf",A, POS$, i%
  Open path$+"modify.dbf Select name , age , height From Table2",B,n$,a%,h%
  Open path$+"modify.dbf Select * From Table3",c,n$,a%,h%

c%=1
  while c%<10
     use a
     insert
     A.POS$=num$(c%,2)
     a.i%=c%
     use b
     insert
     B.n$=num$(c%*10,2)
     b.a%=c%*10
     b.h%=c%
     use c
     insert
     c.n$=num$(c%*10,2)
     c.a%=c%*10
     c.h%=c%
     put
     use a
     put
     use b
     put
     c%=c%+1
  ENDWH

  use c
  first
  use b
  first
  use a
  first

  c%=1
  while c%<10
      use a
      te%=5+c%
      val%=a.i%
      exp%=c%
      test:
      next

      use c
      te%=15+c%
      val%=c.a%
      exp%=c%*10
      test:
      next

      use b
      te%=25+c%
      val%=b.h%
      exp%=c%
      test:
      next
      c%=c%+1
   ENDWH


  use c
  first
  use b
  first
  use a
  first

  c%=1
  while c%<10
      use a
      modify
      a.i%=10-c%
      put
      next
      use b
      modify
      b.a%=10-c%
      put
      next
      use c
      modify
      c.a%=10-c%
      put
      next
      C%=c%+1
  ENDWH


  use c
  first
  use b
  first
  use a
  first
  c%=1
  while c%<10

      use a
      te%=35+c%
      val%=a.i%
      exp%=10-c%
      test:
      next

      use b
      te%=45+c%
      val%=b.a%
      exp%=10-c%
      test:
      next

      use c
      te%=55+c%
      val%=c.a%
      exp%=10-c%
      test:
      next
   c%=c%+1
  ENDWH

  use c
  first
  use b
  first
  use a
  first

  c%=1
  while c%<10
      use a
      modify
      a.i%=100-c%
      cancel
      next
      use b
      modify
      b.a%=100-c%
      cancel
      next
      use c
      modify
      c.a%=100-c%
      cancel
      next

   c%=c%+1
  ENDWH

  use c
  first
  use b
  first
  use a
  first
  c%=1
  while c%<10

      use a
      te%=65+c%
      val%=a.i%
      exp%=10-c%
      test:
      next

      use b
      te%=75+c%
      val%=b.a%
      exp%=10-c%
      test:
      next

      use c
      te%=85+c%
      val%=c.a%
      exp%=10-c%
      test:
      next

  c%=c%+1
  ENDWH
onerr e1
  REM print "testing err: 'file already open for delete table'"
  Delete path$+"modify.dbf","Table1"
  REM print "Failed to get error"
e1::
	onerr off
	if err<>-101 rem File already open
		REM print "Got unexpected error", err,err$(err)
		raise 6
	endif
close
close
close
  Delete path$+"modify.dbf","Table1"

  Delete path$+"modify.dbf","Table3"
  Open path$+"modify.dbf SELECT * FROM Table2",B,n$,a%,h%


onerr e2
  REM print "testing err: 'table not exist'"
  Open path$+"modify.dbf SELECT * FROM Table3",d,n$,a%,h%
  REM print "Failed to get error"
e2::
	onerr off
	if err<>-33 rem File file does not exist
		REM print "Got unexpected error", err,err$(err)
		raise 7
	endif

close          rem need dbase close to create table

create path$+"modify.dbf FIELDS age, name , height TO Table3",c,a%,n$,h%

use c
insert
c.a%=100
put
append
append

      te%=100
      val%=count
      exp%=3
      test:
first
modify
c.a%=50

onerr e3
  REM print "testing err: 'INCOMPATIBLE UPDATE MODE'"
  append
  REM print "Failed to get error"
e3::
	onerr off
	if err<>-125
  REM print "Got unexpected error", err,err$(err)
  raise 8
	endif

 put
 te%=101
 val%=c.a%
 exp%=50
 test:

c.a%=51
onerr e4
  REM print "testing err: 'INCOMPATIBLE UPDATE MODE'"
  MODIFY
  REM print "Failed to get error"
e4::
	onerr off
	if err<>-125
  REM print "Got unexpected error", err,err$(err)
  raise 9
	endif

CANCEL
MODIFY
C.a%=90
put

 te%=102
 val%=c.a%
 exp%=90
 test:
close

REM print"testing Bookmarks!"
create path$+"modify.dbf FIELDS age,name TO Table9",a,a%,n$

  c%=1
    while c%<21
       insert
       a.a%=c%
       put
       b%(c%)=bookmark
        te%=102+c%
        val%=b%(c%)
        exp%=c%
        test:
      c%=c%+1
    ENDWH


    c%=1
     while c%<21
        gotoMark 21-c%
         te%=123+c%
         val%=a.a%
         exp%=21-c%
         test:
         c%=c%+1
      ENDWH

    c%=1
    while c%<11
  	   killMark b%(c%)
         c%=c%+1
      ENDWH

    c%=1
     while c%<11
  	   first
  	   position 11-c%
  	   b%(c%)=bookmark
         te%=133+c%
         val%=b%(c%)
         exp%=c%
         test:
         c%=c%+1
      ENDWH

      c%=1
     while c%<11
    	   gotoMark b%(c%)
         te%=c%+143
         val%=a.a%
         exp%=11-c%
         test:
         c%=c%+1
      ENDWH

   Open path$+"modify.dbf Select name  From Table2",B,n$

   d%=count
   c%=0
   first
   while c%<d%
      erase
      c%=c%+1
   ENDWH

   te%=154
   val%=count
   exp%=0
   test:

   te%=155
   val%=eof
   exp%=-1
   test:

   use b
  d%=count
  c%=0
  first
  while c%<d%
      erase
      c%=c%+1
  ENDWH

  te%=156
  val%=count
  exp%=0
  test:

  te%=157
  val%=eof
  exp%=-1
  test:

  c%=1
  while c%<21
      use a
      A.n$=num$(c%,2)
      append
      use b
      b.n$=num$(c%,2)
      append
      c%=c%+1
   ENDWH

   c%=1
   d%=9


   while c%<21
   use a
       first
       Find(num$(c%,2))
       b%((c%*2)-1)=bookmark
       use b
rem       first
rem       FindField(num$(c%,2),1,1,32)   wanna use it but translator broken
       last
       e%=1
       while b.n$<>num$(c%,2)
             if e%>30
                BREAK
             else
                back
             endif
       e%=e%+1
       endwh
       b%(c%*2)=bookmark
       c%=c%+1
   ENDWH

   c%=1
   while c%<21
       use a
       gotomark b%((c%*2)-1)
    te%=157+c%
    val$=a.n$
    exp$=num$(c%,2)
    tests:
       use b
       gotomark b%(c%*2)
    te%=177+c%
    val$=B.n$
    exp$=num$(c%,2)
    tests:
       c%=c%+1
   ENDWH


onerr e5
  REM print "testing err: 'bad bookmark'"

  use a
  gotomark b%(2)
  REM print "Failed to get error"
  if 0
e5::
  	onerr off
	  if err<>-33 rem bad mark
    REM print "Got unexpected error", err,err$(err)
    		raise 10
	  endif
  endif
onerr e6
  REM print "testing err: 'bad bookmark 2'"

  use a
  gotomark 999
  REM print "Failed to get error"
  if 0
e6::
  	onerr off
	  if err<>-2 rem syntax
		  REM print "Got unexpected error", err,err$(err)
		  raise 11
	  endif
  endif


  trap close
  trap close
  trap close
  trap close
  trap delete path$+"BEN.dbf"

  create path$+"BEN.dbf",a,x%,y%
  c%=1
  while c%<10
  a.x%=c%
  a.y%=c%

  te%=202+c%
  val%=a.x%
  exp%=c%
  test:

  te%=212+c%
  val%=a.y%
  exp%=c%
  test:

  te%=222+c%
  val%=a.y%
  exp%=c%
  test:

  append
  modify

  a.x%=a.x%*2
  a.y%=a.y%*2

  te%=232+c%
  val%=a.x%
  exp%=c%*2
  test:

  te%=242+c%
  val%=a.y%
  exp%=c%*2
  test:

  put

  c%=c%+1
  endwh

  REM print te%;" tests complete"
  REM get

endp


proc tests:
 if exp$<>val$
 REM print "error found in test:", te%
 REM print " press a key to continue"
 REM get
 	raise 100
 endif
endp


proc test:
 if exp%<>val%
 REM print "error found in test:", te%
 REM print "value received was ",val%
 REM print"were expecting ",exp%
 REM print " press a key to continue"
 REM get
 	raise 101
 endif
endp


REM End of plb_dbas.tpl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -