home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Utilities / MUIbase / PortingABPrograms < prev    next >
Text File  |  1997-05-25  |  12KB  |  334 lines

  1. Porting AmigaBase programs to MUIbase programs
  2. ==============================================
  3.  
  4. The following is a brief guide on how to port AmigaBase
  5. programs to MUIbase programs.
  6.  
  7. Here is a note from Ralph Reuchlein about programming MUIbase:
  8.  
  9.     "Please comment amap (as much as possible ;-) ) in MUIbase programs!
  10.     Because  of the crowd of parentheses one should comment every action
  11.     either for himself or for others who have to work with the database."
  12.  
  13.  
  14. Integer ranges
  15. ==============
  16.  
  17. In MUIbase all integer ranges start with zero and end with
  18. the number of items minus 1.  The following section gives a
  19. more detailed list of all affected structures.
  20.  
  21. Internal values of CHOICE values
  22. --------------------------------
  23.  
  24. In MUIbase internal numbers of CHOICE fields are in the
  25. range of 0...(num-labels - 1) whereas in AmigaBase they are
  26. in the range of 1..num-labels.
  27.  
  28. Character index in strings
  29. --------------------------
  30.  
  31. The first character in a MUIbase string has index 0, whereas
  32. in AmigaBase it has index 1.
  33.  
  34. Line index in memos
  35. -------------------
  36.  
  37. The first line of a MUIbase memo has index 0, whereas in
  38. AmigaBase it has index 1.
  39.  
  40.  
  41. String comparison
  42. =================
  43.  
  44. When comparing strings in MUIbase by calling (= string1 string2)
  45. case-sensitive string comparison is used, whereas AmigaBase uses
  46. case-insensitive string comparison when calling (string1 = string2).
  47. In MUIbase you can do case-insensitive string comparison by using
  48. (=* string1 string2)
  49.  
  50.  
  51. Non-strict functions
  52. ====================
  53.  
  54. In MUIbase AND and OR are implemented in a non-strict way, whereas in
  55. AmigaBase they are strict. Non-strict means that not necessary all arguments
  56. of the AND or OR expression are evaluated, e.g. in (AND NIL (PRINTF "Hello"))
  57. no output is done because AND does not need to evaluate the (PRINTF "Hello")
  58. expression.
  59.  
  60.  
  61. Table of function equivalents
  62. =============================
  63.  
  64. The following gives an overview on how to replace AmigaBase functions
  65. with MUIbase functions.
  66.  
  67. A minus sign in the MUIbase column indicates that the corresponding
  68. AmigaBase function will not be implemented in MUIbase.
  69.  
  70.  
  71. 1. Program flow control
  72.  
  73. AmigaBase                       MUIbase
  74. ------------------------------------------------------------
  75. IF expr THEN true-expr          (IF expr (true-expr) (false-expr))
  76. ELSE false-expr
  77. END
  78.  
  79. ERROR                           (ERROR error-string)
  80. HALT                            (HALT)
  81. RETURN                          (RETURN)
  82. RETURN(value)                   (RETURN value)
  83.  
  84.  
  85. 2. Loops
  86.  
  87. AmigaBase                       MUIbase
  88. ------------------------------------------------------------
  89. FOR i := 0 TO n-1 DO            (DOTIMES (i n) cmds)
  90.     cmds
  91. END
  92.  
  93. FOR i := start TO end DO        (DO ((i start (1+ i)))
  94.     cmds                            ((> i end))
  95. END                                 cmds
  96.                                 )
  97.  
  98. FOR i := start TO end           (DO ((i start (+ i step)))
  99. BY step DO                          ((IF (> step 0)
  100.     cmds                                (> i end)
  101. END                                     (< i end)
  102.                                     ))
  103.                                     cmds
  104.                                 )
  105.  
  106. WHILE expr DO                   (DO () ((NOT expr)) cmds)
  107.     cmds
  108. END
  109.  
  110. WITH ALL Rec DO                 (FOR ALL Rec DO cmds)
  111.     cmds
  112. END
  113.  
  114. WITH ALL Rec1 OF Rec2 DO        -
  115.     cmds
  116. END
  117.  
  118. EXIT                            (EXIT)
  119. NEXT                            (NEXT)
  120.  
  121.  
  122. 3. Constants
  123.  
  124. AmigaBase                       MUIbase
  125. ------------------------------------------------------------
  126. TRUE                            TRUE
  127. FALSE                           NIL
  128. NIL                             NIL
  129. NODATE                          NIL
  130. NOTIME                          NIL
  131. OFF                             -
  132. ON                              -
  133.  
  134.  
  135. 4. Conversion functions
  136.  
  137. AmigaBase                       MUIbase
  138. ------------------------------------------------------------
  139. INTSTR(i)                       (STR i)
  140. REALSTR(r, n, e)                (IF (= e 0)
  141.                                     (SPRINTF "%.*f" n r)
  142.                                     (SPRINTF "%.*e" n r)
  143.                                 )
  144. DATESTR(d, s)                   (IF d (STR d) s)
  145. TIMESTR(t, s)                   (IF t (STR t) s)
  146. MEMOSTR(m, n)                   (LINE m n)
  147. CHOICESTR(c)                    (STR c)
  148. CHOICEVAL(c)                    (INT c) or c
  149. CHOICELABELS(c)                 (GETLABELS c)
  150. STR(x)                          (STR x)
  151. VAL(x)                          (REAL x)
  152. STRTODATE(s)                    (DATE s)
  153. STRTOTIME(s)                    (TIME s)
  154.  
  155.  
  156. 5. Boolean functions
  157.  
  158. AmigaBase                       MUIbase
  159. ------------------------------------------------------------
  160. a AND b                         (AND a b)
  161. a OR b                          (OR a b)
  162. NOT(a)                          (NOT a)
  163.  
  164.  
  165. 6. String processing functions
  166.  
  167. AmigaBase                       MUIbase
  168. ------------------------------------------------------------
  169. LEN(s)                          (LEN s)
  170. LEFTSTR(s, n)                   (LEFTSTR s n)
  171. RIGHTSTR(s, n)                  (RIGHTSTR s n)
  172. MIDSTR(s, p)                    (MIDSTR s p NIL)
  173. MIDSTR(s, p, n)                 (MIDSTR s p n)
  174. FORMAT(s, n, d)                 -
  175. STRSTR(s, n)                    -
  176. UPPERSTR(s)                     (UPPER s)
  177. LOWERSTR(s)                     (LOWER s)
  178. TRIMSTR(s)                      (TRIMSTR s)
  179. INDEXSTR(s, t)                  (INDEXSTR* s t)
  180. INDEXBRK(s, t)                  (INDEXBRK* s t)
  181. SPRINTF(fmt, par, ...)          (SPRINTF fmt par ...)
  182. STRCMP(s, t)                    (= s t)
  183. JOKERCMP(s, j)                  (LIKE s j)
  184. STRSIZE(s)                      (MAXLEN s)
  185.  
  186.  
  187. 7. Memo processing functions
  188.  
  189. AmigaBase                       MUIbase
  190. ------------------------------------------------------------
  191. MEMOLINES(m)                    (LINES m)
  192. MEMOSTR(m, n)                   (LINE m n)
  193. MEMOSET(m, s, n)                -
  194. MEMOINS(m, s, n)                -
  195. MEMODEL(m, p, n)                -
  196. MEMOSORT(m)                     (LISTTOMEMO (SORTLISTGT > (MEMOTOLIST m)))
  197. MEMOFILL(m)                     (FILLMEMO m)
  198. MEMOLOAD(m , filename)          - can be replaced by:
  199.                                 (LET ((file (FOPEN filename "r")))
  200.                                     (IF (NOT file) (ERROR "Can't open %s" filename))
  201.                                     (SETQ m (FGETMEMO file))
  202.                                     (FCLOSE file)
  203.                                 )
  204. MEMOSAVE(m, filename)           - can be replaced by:
  205.                                 (LET ((file (FOPEN filename "w")))
  206.                                     (IF (NOT file) (ERROR "Can't open %s" filename))
  207.                                     (FPUTMEMO m file))
  208.                                     (FCLOSE file)
  209.                                 )
  210. SHOW(m)                         (SETWINDOWOPEN m TRUE)
  211. CLOSE(m)                        (SETWINDOWOPEN m FALSE)
  212.  
  213.  
  214. 8. Floating point processing functions
  215.  
  216. AmigaBase                       MUIbase
  217. ------------------------------------------------------------
  218. TRUNC(r)                -       (TRUNC r)
  219. ROUND(r, i)             -       (ROUND r i)
  220. VAL(x)                          (REAL x)
  221. REALSTR(r, n, e)                (IF (= e 0)
  222.                                     (SPRINTF "%.*f" n r)
  223.                                     (SPRINTF "%.*e" n r)
  224.                                 )
  225.  
  226. 9. Calling other functions
  227.  
  228. AmigaBase                       MUIbase
  229. ------------------------------------------------------------
  230. CALC(var)                       (SETQ* var new-value)
  231. _Func(arg1, ...)                (_Func arg1 ...)
  232. PRENEWDATASET(r)
  233. POSTNEWDATASET(r)               (NEW* r ...)
  234. PREDELETEDATASET(r)
  235. POSTDELETEDATASET(r)            (DELETE* r ...)
  236.  
  237. 10. Functions for tables/records
  238.  
  239. AmigaBase                       MUIbase
  240. ------------------------------------------------------------
  241. NEW(r)                          (NEW r NIL)
  242. DELETE(r)                       (DELETE r NIL)
  243. ORDER(r)                        - order is always correct
  244. GETORDERSTR(r)                  (GETORDERSTR r)
  245. SETORDERSTR(r attrs)            (SETORDERSTR r attrs)
  246. SHOW(r)                         ((SETQ r* r) (SETWINDOWOPEN r TRUE))
  247. CLOSE(r)                        (SETWINDOWOPEN r FALSE)
  248. MATCHFILTER(r)                  (GETMATCHFILTER r)
  249. GETFILTER(r)                    (GETFILTERACTIVE r)
  250. SETFILTER(r, b)                 (SETFILTERACTIVE r b)
  251. GETFILTERSTR(r)                 (GETFILTERSTR r)
  252. SETFILTERSTR(r, s)              (SETFILTERSTR r s)
  253. RECNAME(r)                      (TABLENAME r)
  254. GETDNUM(r1, r2)                 (RECNUM r1)¹
  255. EXISTSDNUM(n, r1, r2)           (RECORD r1 n)¹
  256. EXISTSRELDNUM(n, r1, r2)        (RECORD r1 (+ (RECNUM r1) n))¹
  257. SETDNUM(n, r1, r2)              (SETQ r (RECORD r1 n))¹
  258. SETRELDNUM(n, r1, r2)           (SETQ r (RECORD r1 (+ (RECNUM r1 n))))¹
  259. DNUMS(r1, r2, f)                (IF f (RECORDS r1*) (RECORDS r1))¹
  260. PUSH(record)                    - (you may use a global variable (list)
  261. POP(record)                     - for this purpose).
  262.  
  263. ¹) Does not match exactly as MUIbase is not hierarchical.
  264.  
  265.  
  266. 11. Functions for variables/attributes
  267.  
  268. AmigaBase                       MUIbase
  269. ------------------------------------------------------------
  270. PROTECT(var, flag)              (SETDISABLED var flag)
  271. PEN(var, color)                 - no front pen colors yet
  272. VARNAME(var)                    (ATTRNAME var)
  273.  
  274.  
  275. 12. Functions for requesting input from the user
  276.  
  277. AmigaBase                       MUIbase
  278. ------------------------------------------------------------
  279. REQUEST(text, l, m, r)          (ASKBUTTON NIL text (LIST l m) r)¹
  280.  
  281. MULTIREQUEST(text,              (ASKBUTTON NIL text (LIST t1 t2 ...) tn)¹
  282.         "t1|t2...tn")
  283.  
  284. CHOOSEITEM(title, items,        (ASKCHOICE title oktext
  285.         oktext)                         (MEMOTOLIST items) NIL)
  286.  
  287. CHOOSESTRING(title, items,      (ASKCHOICESTR title oktext
  288.         oktext)                         (MEMOTOLIST items) NIL)
  289.  
  290. SELECTFILE(title, filename)     (ASKFILE title NIL filename TRUE)
  291.  
  292. INPUT(title, edit)              (ASKSTR title NIL edit NIL)
  293.  
  294. ¹) Return value has different meaning in MUIbase.
  295.  
  296.  
  297. 13. Functions for output
  298.  
  299. AmigaBase                       MUIbase
  300. ------------------------------------------------------------
  301. OPENOUTPUT(name, a)             (FOPEN name "w") or (FOPEN name "a")
  302. CLOSEOUTPUT                     (FCLOSE ...)
  303. PRINT(s)                        (PRINTF "%s" s)
  304. PRINTF(fmt, par, ...)           (PRINTF fmt par ...)
  305. PRINTLN                         (PRINTF "\n")
  306. PRINTMEMO(m, t)                 (DOLIST (s (MEMOTOLIST m))
  307.                                     (PRINTF "%.*s%s" t "" s)
  308.                                 )
  309. RESET                           (PRINTF RESET)
  310. DRAFT                           (PRINTF NLQOFF)
  311. NLQ                             (PRINTF NLQON)
  312. ELITE(f)                        (PRINTF (IF f ELITEON ELITEOFF))
  313. NORMAL                          (PRINTF NORMAL)
  314. BOLD(f)                         (PRINTF (IF f BFON BFOFF))
  315. ITALIC(f)                       (PRINTF (IF f ITON ITOFF))
  316. UNDERLINED(f)                   (PRINTF (IF f ULON ULOFF))
  317. WIDE(f)                         (PRINTF (IF f WIDEON WIDEOFF))
  318. CONDENSED(f)                    (PRINTF (IF f CONDON CONDOFF))
  319.  
  320.  
  321. 14. Misc functions
  322.  
  323. AmigaBase                       MUIbase
  324. ------------------------------------------------------------
  325. CALL(command)                   (SYSTEM command)
  326. EXISTS(filename)                (STAT filename)
  327. TODAY                           (TODAY)
  328. NOW                             (NOW)
  329. BUSY(f)                         -
  330. FILENAME                        -
  331. CHANGES                         (CHANGES)
  332. AREXXPORT                       - no ARexx interface yet.
  333.  
  334.