home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / 1997 / 944 / EXAB.MCR next >
Encoding:
Text File  |  1997-03-02  |  6.8 KB  |  369 lines

  1. PROC macro:
  2. global c$(1),d$(30),e$(1),l$(255),n$(36),r$(2),s$(255),t$(3),v$(3),a%,i%,r%,t
  3.  
  4. rem ███████████████████████████████████████
  5. rem █ ExAb - ╕Huub Linthorst, 96-97       █
  6. rem █ Macro to EXtend ABbreviations       █
  7. rem █ E-mail: linthors@chem.leidenuniv.nl █
  8. rem ███████████████████████████████████████
  9.  
  10. c$="+" rem whole text indicator
  11. r$="/" rem linefeed indicator
  12. e$="m" rem JBMACFIX.OPO drive (if present)
  13.  
  14. n$="ExAb v.1.7c - ╕Huub Linthorst, 96-97"
  15. v$="17c"
  16.  
  17. useapp:("active")
  18. if Pid2App$:(CurrPid%:)= "Program"
  19.     d$="ExabP"
  20. else
  21.     d$="Exab"
  22. endif
  23.  
  24. sendkey:(left%,ctrl%+shift%,1)
  25. p1:
  26. if s$=""
  27.     gettext$:
  28.     goto x::
  29. endif
  30. if s$=c$+c$
  31.     delete:
  32.     a%=1
  33.     giprint:("ExAb will search whole text...")
  34.     p2:
  35. else 
  36.     p3:
  37. endif
  38. x::
  39. endp
  40.  
  41. proc p3:
  42. if exist ("loc::m:\dat\"+d$+".DBF")
  43.     open "loc::m:\dat\"+d$+".DBF",D,k$,l$
  44.     last
  45.     p4:
  46. else
  47.     p6:
  48. endif
  49. endp
  50.  
  51. proc p4:
  52. if s$=".?"
  53.     delete:
  54.     p10:
  55.     if r%=0
  56.         goto x::
  57.     endif
  58.     p4:
  59. elseif s$=".d"
  60.     delete:
  61.     puttext:(mid$(datim$,5,11))
  62.     goto x::
  63. elseif s$=".t"
  64.     delete:
  65.     puttext:(mid$(datim$,17,8))
  66.     goto x::
  67. else
  68.     l$=lower$(mid$(s$,loc(s$,".")+1,3))
  69.     if l$="dbf"
  70.         l$="data"
  71.     elseif l$="wrd"
  72.         l$="word"
  73.     elseif l$="agn"
  74.         l$="agenda"
  75.     elseif l$="spr"
  76.         l$="sheet"
  77.     else
  78.         l$=""
  79.         goto c::
  80.     endif
  81.     delete:
  82.     if exist ("loc::"+e$+":\app\jbmacfix.opo")
  83.         runjb:(l$,s$,actpid%:)
  84.     else 
  85.         runappc:(l$,s$)
  86.     endif
  87. endif
  88. c::
  89. if len(s$)>10
  90.     i%=1
  91.     s$=mid$(s$,1,10)
  92. endif
  93.  
  94. position 1
  95. while (not eof) and (s$<>D.k$)
  96.     next
  97. endwh
  98. if s$=D.k$
  99.     delete:
  100.     p7:
  101. elseif (eof) and s$<>D.k$
  102.     if pos>100
  103.         beep:(8,600)
  104.         giprint:("Maximum number reached...")
  105.         goto z::
  106.     endif
  107.     dinit:(n$)
  108.     dtext:("","Enter full text for '"+s$+"'    (<┘ = "+r$+")",2)
  109.     dedit:(addr(l$),s$,24)
  110.     if i%=1
  111.         beep:(8,600)
  112.         giprint:("Abbreviations 10 characters max.")
  113.     endif
  114.     if a%<>0
  115.         beep:(8,600)
  116.         dtext:("","<Enter> continue '"+c$+"' search, <Esc> quit",2)
  117.     endif
  118.     r%=Dialog:
  119.     if r%=1
  120.         if l$=""
  121.             goto x::
  122.         else
  123.             D.l$=l$
  124.             D.k$=s$
  125.             append
  126.             giprint:("Record no. "+num$(pos,3)+" appended...")
  127.             tofront:
  128.             delete:
  129.             p7:
  130.         endif
  131.     else
  132.         goto z::
  133.     endif
  134. endif
  135. t=t+1
  136. x::
  137. i%=0
  138. if a%<>0
  139.     right:
  140.     if r%=1 and l$=""
  141.         right:
  142.         r%=0
  143.         goto y::
  144.     endif
  145.     sendkey:(127,2,1)
  146.     y::
  147.     a%=2
  148.     p2:
  149. endif
  150. z::
  151. close
  152. right:
  153. endp
  154.  
  155. proc p2:
  156. if a%=2
  157.     psion:(%g)
  158.     goto y::
  159. endif
  160. psion:(%f)
  161. sendtext:(c$)
  162. enter:
  163. y::
  164. p1:
  165. if s$=c$
  166.     sendkey:(259,6,1)
  167. else
  168.     a%=0
  169.     goto x::
  170. endif
  171. p1:
  172. l$=""
  173. if a%=1
  174.     p3:
  175. elseif a%=2
  176.     p4:
  177. endif
  178. x::
  179. close
  180. beep:(8,600)
  181. giprint:("ExAb finished extending "+num$(t,4)+" abbreviations")
  182. endp
  183.  
  184. proc p1:
  185. if currpid%:<>srvpid%:
  186.     tomacro:
  187.     tofront:
  188. endif
  189. if testsrv%:=0
  190. s$=gettext$:
  191. return
  192. else
  193. return
  194. endif
  195. endp
  196.  
  197. proc p5:
  198. append
  199. p7:
  200. esc:
  201. sendkey:(259,6,1)
  202. delete:
  203. return
  204. endp
  205.  
  206. proc p6:
  207. giprint:("Welcome to ExAb, one moment please...")
  208. create "loc::m:\dat\"+d$+".DBF",D,k$,l$
  209.  
  210. rem ---This line and the lines down to the next rem-line contain on-line info and may be removed
  211. if exist ("loc::m:\wrd\exab"+v$+".wrd")
  212.     goto x::
  213. endif
  214. s$=""
  215. runappc:("word","loc::m:\wrd\exab"+v$+".wrd")
  216. sendkey:(260,12,1)
  217. enter:
  218. enter:
  219. D.k$="exab"
  220. D.l$=n$+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"
  221. p5:
  222. sendkey:(259,6,13)
  223. delete:
  224. D.k$="help"
  225. 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"
  226. p5:
  227. D.k$="hot-key..1"
  228. 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"
  229. p5:
  230. D.k$="hot-key..2"
  231. 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"
  232. p5:
  233. D.k$="hot-key..3"
  234. D.l$=r$+"'Exabbing' on special codes '.t' and '.d' will stamp the time and date, respectively, while hot-keying on '.?' opens ExAb's definitions screen for quick reference. hot-key..4"
  235. p5:
  236. D.k$="hot-key..4"
  237. 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"
  238. p5:
  239. enter:
  240. D.k$="hot-key..5"
  241. D.l$=r$+r$+"Now try ExAb yourself with sy"
  242. append
  243. close
  244. sendkey:(260,12,1)
  245. rem ---This line and the lines up to the previous rem-line may be removed
  246. x::
  247. p4:
  248. return
  249. endp
  250.  
  251. proc p7:
  252. l$=D.l$
  253. while loc(l$,r$)<>0
  254.     l$=mid$(l$,1,(loc(l$,r$)-1))+chr$(000)+mid$(l$,(loc(l$,r$)+1),len(l$))
  255. endwh
  256. puttext:(l$)
  257. return
  258. endp
  259.  
  260. proc p8:
  261. local m1$(100,10),m$(100,43),q$(3)
  262. giprint:("ExAb is loading definitions...")
  263. position 1
  264. while not eof
  265.     m1$(pos)=D.k$
  266.     if len(D.l$)<21
  267.         q$=""
  268.     else
  269.         q$="..."
  270.     endif
  271.     m$(pos)=m1$(pos)+"  :  "+mid$(D.l$,1,20)+q$
  272.     next
  273. endwh
  274. dinit:("ExAb definitions ("+num$(pos-1,3)+")")
  275. dchoicea:(1,"",addr(m$()),pos-1)
  276. dtext:("","<Enter> = paste extension",2)
  277. r%=dialog: 
  278. if r%<>0
  279.     puttext:(" "+m1$(r%))
  280.     s$=m1$(r%)
  281. endif
  282. endp
  283.  
  284. proc p10:
  285. dinit:("ExAb Database ("+d$+".dbf)")
  286. dbuttons:("List,%l,Open,%o,Sort,%s")
  287. r%=dialog:
  288. if r%=1
  289.     p8:
  290.     return
  291. elseif r%=2
  292.     if exist ("loc::"+e$+":\app\jbmacfix.opo")
  293.         runjb:("Data","m:\dat\"+d$+".dbf",actpid%:)
  294.     else 
  295.         runappc:("data","m:\dat\"+d$+".dbf")
  296.     endif
  297. elseif r%=3
  298.     p9:
  299. else
  300.     s$=""
  301. endif
  302. r%=0
  303. endp
  304.  
  305. proc testsrv%:
  306. local wsrv$(15),in%(6),fmt&,pid%,pfmt%
  307. wsrv$="sys$wsrv.*"+chr$(0)
  308. in%(1)=$100
  309. in%(2)=uadd(addr(wsrv$),1)
  310. if os($88,addr(in%(1))) and 1
  311.     return(in%(1) and $ff)-$100
  312. else
  313.     pid%=in%(1)
  314. endif
  315. pfmt%=addr(fmt&)
  316. if call($683,pid%,4,0,addr(pfmt%),0)<=0
  317.     return -33
  318. endif
  319. if (fmt& and $16)=0
  320.     return -36
  321. endif
  322. endp
  323.  
  324. proc runjb:(a$,f$,act%)
  325. rem ╕JBSoft 1996
  326. local buf%(128),name$(128),p%(6)
  327. close
  328. name$="JBMSRS"
  329. pokew addr(buf%()),act%
  330. poke$ uadd(addr(buf%()),2),a$
  331. poke$ uadd(addr(buf%()),3+len(a$)),f$
  332. call($228b,0,255,6,addr(buf%()),addr(name$)+1)
  333. name$=parse$("jbmacfix.opo",cmd$(1),p%())
  334. runapp:(name$,"")
  335. endp
  336.  
  337. proc p9:
  338. local z%,g$(10),g%,lp%,n$(128),c%
  339. last
  340. z%=pos
  341. if count>7
  342.     tomacro:
  343.     busy "Sorting database...",0
  344.     while z%>0
  345.         position z% 
  346.         g%=pos
  347.         g$=upper$(D.k$)
  348.         do
  349.             if upper$(D.k$)<g$
  350.                 g$=upper$(D.k$)
  351.                 g%=pos
  352.             endif
  353.             lp%=pos
  354.             back
  355.         until pos=1 and lp%=1
  356.         position g%
  357.         print g$
  358.         update
  359.         z%=z%-1
  360.     endwh
  361. endif
  362. close
  363. tofront:
  364. busy off
  365. beep:(6,500)
  366. giprint:("Database sorted. Thanks for waiting...")
  367. endp
  368.  
  369.