home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / 1997 / 997.ZIP / EXAB.MCR next >
Encoding:
Text File  |  1997-04-23  |  10.1 KB  |  497 lines

  1. rem ╔═════════════════════════════════════╗
  2. rem ║ ExAb - ╕Huub Linthorst, 96-97       ║
  3. rem ║ Macro to EXtend ABbreviations       ║
  4. rem ║ E-mail: linthors@chem.leidenuniv.nl ║
  5. rem ╚═════════════════════════════════════╝
  6.  
  7. PROC macro:
  8. global a$(8),b$(30),c$(1),d$(11),e$(1),f$(20),g$(3),h$(1),l$(255),r$(2),s$(255),t$(3),v$(36),a%,i%,l%,r%,t
  9. v$="(1.8e) ─ ╕Huub Linthorst, 96-97"
  10.  
  11. rem ───THE FOLLOWING LINES ASSIGN USER DEFINABLE VARIABLES───
  12.  
  13. c$="+"    rem Whole text search indicator
  14. r$="/"    rem Linefeed indicator
  15. h$=">"    rem Extension chain indicator
  16. e$="M"    rem JBMACFIX.OPO drive (if present)
  17. g$="Yes"  rem Case sensitivity
  18. rem USE EITHER OF THE NEXT TWO LINES (put rem in front of the other)
  19. d$=gen$(day,2)+"-"+gen$(month,2)+"-"+gen$(year,4) rem date format 23-2-1997
  20. rem d$=mid$(datim$,5,11) rem date format 23 Feb 1997
  21.  
  22. rem ───DO NOT CHANGE ANYTHING BELOW THIS LINE! (unless you're an expert)───
  23.  
  24. useapp:("active")
  25. a$=Pid2App$:(CurrPid%:)
  26. if a$="program"
  27.     b$="EXABP"
  28. else
  29.     b$="EXAB"
  30. endif
  31. sendkey:(left%,ctrl%+shift%,1)
  32. p1:
  33. if s$=""
  34.     gettext$:
  35.     goto x::
  36. endif
  37. if s$=c$+c$
  38.     delete:
  39.     a%=1
  40.     giprint:("ExAb will search whole text...")
  41.     p2:
  42. else 
  43.     p3:
  44. endif
  45. x::
  46. endp
  47.  
  48. proc p3:
  49. if exist ("loc::m:\dat\"+b$+".DBF")
  50.     trap open "loc::m:\dat\"+b$+".DBF",D,k$,l$
  51.     if err
  52.         beep:(5,700)
  53.         dinit:("Error: "+err$(err))
  54.         dtext:("","Database "+b$+" may be in use by other program",2)
  55.         dtext:("","Do you want ExAb to try close the database?",2)
  56.         dbuttons:("Yes,%y,No,%n")
  57.         r%=dialog:
  58.         if r%=1
  59.             usefile:(b$+".dbf")
  60.             exit:
  61.             useapp:(a$)
  62.             p3:
  63.         else
  64.             right:
  65.         endif
  66.     endif
  67.     last
  68.     p4:
  69. else
  70.     p6:
  71. endif
  72. endp
  73.  
  74. proc p4:
  75. if s$=".?"
  76.     delete:
  77.     p10:
  78.     if r%=0
  79.         goto x::
  80.     endif
  81.     p4:
  82. elseif s$=".d"
  83.     delete:
  84. puttext:(d$)
  85.     goto x::
  86. elseif s$=".t"
  87.     delete:
  88.     puttext:(mid$(datim$,17,8))
  89.     goto x::
  90. else
  91.     l$=lower$(mid$(s$,loc(s$,".")+1,3))
  92.     if l$="dbf"
  93.         l$="Data"
  94.     elseif l$="wrd"
  95.         l$="Word"
  96.     elseif l$="agn"
  97.         l$="Agenda"
  98.     elseif l$="spr"
  99.         l$="Sheet"
  100.     else
  101.         l$=""
  102.         goto c::
  103.     endif
  104.     delete:
  105.     if left$(s$,1)="."
  106.         dinit:("ExAb will open "+l$+" file")
  107.         dtext:("","",2)
  108.         dedit:(addr(s$),"Enter filename",10)
  109.         dtext:("","",$202)
  110.         dtext:("","If not found, file will be created",2)
  111.         r%=dialog:
  112.         if r%=1
  113.         else
  114.             goto z::
  115.         endif
  116.     endif
  117.     if loc(s$,".")>0
  118.         s$=left$(s$,loc(s$,".")-1)
  119.     endif
  120.     s$=left$(s$,8)
  121.     if exist ("loc::"+e$+":\app\jbmacfix.opo")
  122.         runjb:(l$,s$,actpid%:)
  123.     else
  124.         runappc:(l$,s$)
  125.         return
  126.     endif
  127. endif
  128. c::
  129. if len(s$)>10
  130.     i%=1
  131.     s$=left$(s$,10)
  132. endif
  133.  
  134. position 1
  135. while (not eof) and (s$<>D.k$)
  136.     next
  137. endwh
  138. if s$=D.k$
  139.     delete:
  140.     p7:
  141. elseif (eof) and s$<>D.k$
  142.     if pos>101
  143.         beep:(8,600)
  144.         giprint:("Maximum number reached...")
  145.         goto z::
  146.     endif
  147.     delete:
  148.     f$=" , <Esc> = input new"
  149.     p8:
  150.     if r%<>0
  151.         p4:
  152.         goto z::
  153.     else
  154.         puttext:(s$)
  155.     endif
  156.     dinit:("Enter full text for '"+s$+"'    (<┘ = "+r$+")")
  157.     dedit:(addr(l$),s$,24)
  158.     if i%=1
  159.         beep:(8,600)
  160.         giprint:("Abbreviations 10 characters max.")
  161.     endif
  162.     if a%<>0
  163.         beep:(8,600)
  164.         dtext:("","<Enter> continue '"+c$+"' search, <Esc> quit",2)
  165.     endif
  166.     r%=dialog:
  167.     if r%=1
  168.         if l$=""
  169.             goto x::
  170.         else
  171.             D.l$=l$
  172.             D.k$=s$
  173.             append
  174.             giprint:("Record no. "+num$(pos,3)+" appended...")
  175.             tofront:
  176.             delete:
  177.             p7:
  178.         endif
  179.     else
  180.         goto z::
  181.     endif
  182. endif
  183. t=t+1
  184.  
  185. if right$(l$,1)=h$
  186.     right:
  187.     delete:
  188.     sendkey:(left%,shift%+ctrl%,1)
  189.     p1:
  190.     p4:
  191. endif
  192.  
  193. x::
  194. i%=0
  195. if a%<>0
  196.     right:
  197.     if r%=1 and l$=""
  198.         right:
  199.         r%=0
  200.         goto y::
  201.     endif
  202.     sendkey:(127,2,1)
  203.     y::
  204.     a%=2
  205.     p2:
  206. endif
  207. z::
  208. close
  209. right:
  210. endp
  211.  
  212. proc p2:
  213. if a%=2
  214.     psion:(%g)
  215.     goto y::
  216. endif
  217. psion:(%f)
  218. sendtext:(c$)
  219. enter:
  220. y::
  221. p1:
  222. if s$=c$
  223.     sendkey:(left%,ctrl%+shift%,1)
  224. else
  225.     a%=0
  226.     goto x::
  227. endif
  228. p1:
  229. l$=""
  230. if a%=1
  231.     p3:
  232. elseif a%=2
  233.     p4:
  234. endif
  235. x::
  236. close
  237. beep:(8,600)
  238. giprint:("ExAb finished extending "+num$(t,4)+" abbreviations")
  239. endp
  240.  
  241. proc p1:
  242. if srvpid%:<>currpid%:
  243.     tomacro:
  244.     tofront:
  245. endif
  246. if testsrv%:=0
  247.     if lower$(g$)="yes"
  248.         s$=gettext$:
  249.     else
  250.         s$=lower$(gettext$:)
  251.     endif
  252.     return
  253. else
  254.     return
  255. endif
  256. endp
  257.  
  258. proc p5:
  259. append
  260. p7:
  261. esc:
  262. sendkey:(259,6,1)
  263. delete:
  264. return
  265. endp
  266.  
  267. proc p6:
  268. giprint:("Welcome to ExAb, one moment please...")
  269. create "loc::m:\dat\"+b$+".DBF",D,k$,l$
  270.  
  271. rem ---This line and the lines down to the next rem-line contain on-line info and may be removed
  272. if exist ("loc::m:\wrd\exab"+mid$(v$,2,1)+mid$(v$,4,2)+".wrd")
  273.     goto x::
  274. endif
  275. s$=""
  276. runappc:("word","loc::m:\wrd\exab"+mid$(v$,2,1)+mid$(v$,4,2)+".wrd")
  277. sendkey:(260,12,1)
  278. enter:
  279. enter:
  280. D.k$="exab"
  281. D.l$="ExAb "+v$+r$+r$+"A Macro to EXtend ABbreviations"+r$+r$+"E-Mail me for comments, suggestions and improvements at linthors@chem.leidenuniv.nl//With the cursor behind the word help, hit the hot-key again to get help"
  282. p5:
  283. sendkey:(259,6,13)
  284. delete:
  285. D.k$="help"
  286. D.l$="ExAb HELP"+r$+r$+"This is how ExAb works. Type an abbreviation, e.g. 'sy'. With the cursor behind 'sy', hit ExAb's hot-key (I use <Psion-Enter>). The macro will search database EXAB for 'sy'. hot-key.1>"
  287. p5:
  288. D.k$="hot-key.1"
  289. D.l$="If found, ExAb will replace 'sy' in your text with the corresponding full text. If not found, ExAb will present an input screen to enable you to add 'Sincerely Yours,' or 'Since Yesterday' to the database. hot-key.2>"
  290. p5:
  291. D.k$="hot-key.2"
  292. D.l$="Alternatively, ExAb can search and replace all abbreviations of a text in one go. Therefore, type a '"+c$+"' at the end of each abbreviation. After finishing, type '"+c$+c$+"' at the start of the text followed by the hot-key. hot-key.3>"
  293. p5:
  294. D.k$="hot-key.3"
  295. D.l$=r$+"'Exabbing' on special codes '.t' and '.d' will stamp the time and date, respectively, while hot-keying on '.?' opens ExAb's information menu for quick reference. hot-key.4>"
  296. p5:
  297. D.k$="hot-key.4"
  298. D.l$=r$+r$+"Database EXAB, is automatically created during installation. It contains these help lines and the abbreviations and extensions that you add during - a hopefully enjoyable - use. Using DATA, you can modify EXAB.DBF. hot-key.5>"
  299. p5:
  300. enter:
  301. D.k$="hot-key.5"
  302. D.l$=r$+r$+"Now try ExAb yourself with sy"
  303. append
  304. close
  305. sendkey:(260,12,1)
  306. rem ---This line and the lines up to the previous rem-line may be removed
  307. x::
  308. dinit:("Welcome to ExAb")
  309. dtext:("","ExAb has created database file EXAB.DBF to store your data.",2)
  310. dtext:("","Please read file EXAB.TXT, included in the ZIP file,",2)
  311. dtext:("","for the latest information on this version.",2)
  312. dtext:("","The present file (EXAB"+mid$(v$,2,1)+mid$(v$,4,2)+".WRD) was created for quick reference.",2)
  313. dtext:("","It is not essential for EXAB's functioning and may be deleted.",$202)
  314. dtext:("","Enjoy ExAb",2)
  315. dialog:
  316. p4:
  317. return
  318. endp
  319.  
  320. proc p7:
  321. l$=D.l$
  322. while loc(l$,r$)<>0
  323.     l$=left$(l$,(loc(l$,r$)-1))+chr$(000)+mid$(l$,(loc(l$,r$)+1),len(l$))
  324. endwh
  325. puttext:(l$)
  326. return
  327. endp
  328.  
  329. proc p8:
  330. local m1$(101,10),m$(101,43),q$(3)
  331. giprint:("ExAb is loading definitions...")
  332. position 1
  333. while not eof
  334.     m1$(pos)=D.k$
  335.     if len(D.l$)<21
  336.         q$=""
  337.     else
  338.         q$="..."
  339.     endif
  340.     m$(pos)=m1$(pos)+" ── "+left$(D.l$,20)+q$
  341.     next
  342. endwh
  343. if len(f$)>0
  344.     dinit:("Abbreviation '"+s$+"' not found")
  345.     dtext:("","",0)
  346.     dtext:("","Choose existing or input new extension",2)
  347. else dinit:("Choose ExAb definition ("+num$(pos-1,3)+")")
  348.     dtext:("","",0)
  349. endif
  350. dchoicea:(1,"",addr(m$()),pos-1)
  351. dtext:("","",$200)
  352. dtext:("","<Enter> = paste"+f$+" extension",2)
  353. r%=dialog: 
  354. if r%<>0
  355.     puttext:(" ")
  356.     s$=m1$(r%)
  357. endif
  358. endp
  359.  
  360. proc p10:
  361. dinit:("ExAb "+v$)
  362. dtext:("","Database: "+b$+".DBF",2)
  363. dbuttons:("List,%l,Codes,%c,Open DB,%o,Sort DB,%s,Info,%i")
  364. r%=dialog:
  365. if r%=1
  366.     p8:
  367.     return
  368. elseif r%=3
  369.     if exist ("loc::"+e$+":\app\jbmacfix.opo")
  370.         runjb:("Data","m:\dat\"+b$+".dbf",actpid%:)
  371.     else
  372.         close 
  373.         runappc:("Data","m:\dat\"+b$+".dbf")
  374.         goto x::
  375.     endif
  376. elseif r%=4
  377.     p9:
  378. elseif r%=2
  379.     dinit:("ExAb special codes")
  380.     dtext:(".d","Stamp date ("+d$+")",$400)
  381.     dtext:(".t","Stamp time ("+(mid$(datim$,17,8))+")",$400)
  382.     dtext:(".?","Present Info menu",$400)
  383.     dtext:(".dbf","Open Data file",$400)
  384.     dtext:(".wrd","Open Word file",$400)
  385.     dtext:(".agn","Open Agenda file",$400)
  386.     dtext:(".spr","Open Sheet file",$600)
  387.     dtext:("exab","ExAb introduction",$400)
  388.     r%=dialog:
  389.     if r%=2
  390.         s$=".d"
  391.     elseif r%=3
  392.         s$=".t"
  393.     elseif r%=4
  394.         s$=".?"
  395.     elseif r%=5
  396.         s$=".dbf"
  397.     elseif r%=6
  398.         s$=".wrd"
  399.     elseif r%=7
  400.         s$=".agn"
  401.     elseif r%=8
  402.         s$=".spr"
  403.     elseif r%=9
  404.         s$="exab"
  405.     else
  406.         goto x::
  407.     endif
  408.     puttext:(" ")
  409.     r%=0
  410.     p4:
  411. elseif r%=5
  412.     dinit:("ExAb configuration")
  413.     dtext:("Whole text search indicator",c$,2)
  414.     dtext:("Linefeed indicator",r$,2)
  415.     dtext:("Extension chain indicator",h$,2)
  416.     dtext:("JBMACFIX.OPO drive",e$,2)
  417.     dtext:("Case sensitivity",g$,2)
  418.     dtext:("Date format",d$,$202)
  419.     dtext:("","Change these settings by editing EXAB.MCR",2)
  420.     dialog:
  421.     dinit:("ExAb "+v$)
  422.     dtext:("","If you like ExAb and wish to receive free updates,",2)
  423.     dtext:("","have your name added to my ExAb user list.",2)
  424.     dtext:("","E-mail me at linthors@chem.leidenuniv.nl",2)
  425.     dialog:
  426. else
  427.     x::
  428.     s$=""
  429. endif
  430. r%=0
  431. endp
  432.  
  433. proc testsrv%:
  434. local wsrv$(15),in%(6),fmt&,pid%,pfmt%
  435. wsrv$="sys$wsrv.*"+chr$(0)
  436. in%(1)=$100
  437. in%(2)=uadd(addr(wsrv$),1)
  438. if os($88,addr(in%(1))) and 1
  439.     return(in%(1) and $ff)-$100
  440. else
  441.     pid%=in%(1)
  442. endif
  443. pfmt%=addr(fmt&)
  444. if call($683,pid%,4,0,addr(pfmt%),0)<=0
  445.     return -33
  446. endif
  447. if (fmt& and $16)=0
  448.     return -36
  449. endif
  450. endp
  451.  
  452. proc runjb:(a$,f$,act%)
  453. rem ╕JBSoft 1996
  454. local buf%(128),name$(128),p%(6)
  455. close
  456. name$="JBMSRS"
  457. pokew addr(buf%()),act%
  458. poke$ uadd(addr(buf%()),2),a$
  459. poke$ uadd(addr(buf%()),3+len(a$)),f$
  460. call($228b,0,255,6,addr(buf%()),addr(name$)+1)
  461. name$=parse$("jbmacfix.opo",cmd$(1),p%())
  462. runapp:(name$,"")
  463. endp
  464.  
  465. proc p9:
  466. local z%,g$(10),g%,lp%,n$(128),c%
  467. last
  468. z%=pos
  469. if count>7
  470.     tomacro:
  471.     busy "Sorting database...",0
  472.     while z%>0
  473.         position z%
  474.         g%=pos
  475.         g$=upper$(D.k$)
  476.         do
  477.             if upper$(D.k$)<g$
  478.                 g$=upper$(D.k$)
  479.                 g%=pos
  480.             endif
  481.             lp%=pos
  482.             back
  483.         until pos=1 and lp%=1
  484.         position g%
  485.         print g$
  486.         update
  487.         z%=z%-1
  488.     endwh
  489. endif
  490. close
  491. tofront:
  492. busy off
  493. beep:(6,500)
  494. giprint:("Database sorted. Thanks for waiting...")
  495. endp
  496.  
  497.