home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / datamage.zip / DOCS.ZIP / MACRO.DOC < prev    next >
Text File  |  1991-02-28  |  15KB  |  291 lines

  1. DATAMAGE MACROS:
  2.  
  3. If  you  have just gotten DATAMAGE and you are browsing the docs  please  don't
  4. read this file.  While rambling about the MACROS I will assume you have a  good
  5. understanding of how the BASE program works, and what it can do.
  6.  
  7. RECORDING AND RUNNING MACROS:
  8.  
  9. DATAMAGE MACROS are recorded from the BROWSE screen of the BASE program.   Once
  10. recorded,  they are executed from there as well.  To record a macro, press Ctrl
  11. +  F-1.   Then  do what you want it to do.  Press Ctrl + F-1 again   to   close
  12. the file.  Your MACRO is now ready to run.
  13.  
  14. To execute a MACRO press Ctrl + F-2.  MACROS can also be run automatically,  at
  15. the exit of a datafile.  To make an automatic MACRO all you need do is to  call
  16. it AUTOEXIT.  This MACRO will run automatically every time a user accesses  the
  17. file and deletes, enters or updates a record.  This feature is usually used  to
  18. maintain MARKER FILES containing groups of records in a certain order.
  19.  
  20. WHAT IS A MACRO?
  21.  
  22. The  help screens liken MACROS to programs, and they are similar in  that  they
  23. are both a way to do a job needing done.  NO ATTEMPT has been made to provide a
  24. full-fledged programming language.
  25.  
  26. You  see, to wield a full-fledged programming language you need to be  a  full-
  27. fledged   programmer.  If you are you will see the facility of  your  datafiles
  28. being  accessible  to your BASIC or C programs.  The DATAMAGE can free  you  of
  29. the  drudgery of writing datafile maintenance into each and every  program  you
  30. originate,  and  provide  your users with many functions not  offered  by  your
  31. program.
  32.  
  33. DATAMAGE  is  designed  to  be totally assimilated  by  your  average  clerical
  34. employee.  And is PURPOSELY LIMITED to what is reasonable to expect of same.
  35.  
  36. Unlike a real programming language, MACROS do not allow the interaction of  the
  37. data  being processed and program control.  They do not embrace the concept  of
  38. LABELS, nor do they allow testing/branching.
  39.  
  40. They  do allow conditional processing; only the records in the group are  acted
  41. upon by many functions.  The functions themselves are fine-tuned to do what  is
  42. necessary  in business datafiles, within the context of your  average  clerical
  43. employee.
  44.  
  45. DATAMAGE is the realization of the concept that any good secretary can program.
  46. If  you  can do an operation on paper files then you can do it to  a  diskfile.
  47. This  idea  would  make  many a programmer awaken at night  in  a  cold  sweat,
  48. concerned about the data in the file.  It has that affect on me, as well.
  49.  
  50. For that reason, DATAMAGE provides many tools not available with, for  example,
  51. BASIC.   The ability to BROWSE the current group and verify the results of  all
  52. operations  done  so  far (provided you remember them)  is  invaluable  to  the
  53. neophyte, and quite useful regardless of the status of the operator.
  54.  
  55. On  the  other  hand,  MACROS  are limited in what  they  can  do,  where  real
  56. programming languages such as C and BASIC are not.
  57.  
  58. So,   first  off,  decide  who  you are.  If  you  are  a  programmer  then   a
  59. QUICK BASIC (Quick C, etc.) compiler will take  you all the way.
  60.  
  61. But, do you need to go all the way?  Or, could you make a quick, easy,  bullet-
  62. proof MACRO that runs from within the DATAMAGE?  Your decision.
  63.  
  64. Or,  would  you  like some sort of hybrid situation, where a  MACRO  does  some
  65. record  selects and calculations, then writes the records in the current  group
  66. and  their  two counters to disk in a MARKER FILE that is read by  your  CUSTOM
  67. program,  the POWER COPY program or the POWER MAIL program?  Or, how about  egg
  68. in your beer?
  69.  
  70. DATAMAGE  imposes no limits; you are CERTAINLY not limited to what a MACRO  can
  71. do.  You are free to put the pieces of the puzzle together any way you wish (we
  72. made  them all square) and to come up with the overall system that  best  suits
  73. your needs.
  74.  
  75. CHEAP INSURANCE:
  76.  
  77. Having written a fair number of random-file programs with C and BASIC, I  don't
  78. think I've ever tested a program on the only copy of a valuable file.  May I be
  79. so bold as to say that you shouldn't, either?
  80.  
  81. The  datafile  structure of DATAMAGE allows quick and  easy  datafile  cloning.
  82. From  the  MAGE directory of C:, enter: MD WORK (test, temp,  target,  whatever
  83. turns  your crank....).  Then CD WORK.  And, finally COPY ..\(dir  name  you're
  84. cloning)\*.*.   Presto,  you've got a copy of the file you can afford  to  blow
  85. away.  When you do, repeat the above process, and try again!
  86.  
  87. TIP #1:  DEVELOP YOUR MACRO IN A TEST ENVIRONMENT!
  88.  
  89. Once  you have established your test environment it becomes a  SIMULATOR.   The
  90. dynamic  factor  in  the MACROS is the data in the files.   In  the  SIMULATION
  91. environment  you  are free to change data in certain records to find  out  what
  92. would happen if....
  93.  
  94. ERROR  TRAPPING:
  95.  
  96. Somewhere  between  1958 and 1960 somebody wrote the  first  computer  program.
  97. Endless quibbling can be done on what constitutes a program, so  the  poor  guy
  98. still, as far as I know, hasn't gotten credit for  it.
  99.  
  100. Soon  after  the first program was written,  or perhaps during  it's  creation,
  101. somebody thought:  WHAT IF  something goes wrong right here....
  102.  
  103. The  concept  of PROGRAMMING and ERROR TRAPPING are of approximately  the  same
  104. age,  and are siamese twins.  Each  time a new  program is created one  of  the
  105. things the PROGRAMMER must do is to separate them, and make them both behave.
  106.  
  107. When  you  write a MACRO you (yep, YOU) are the programmer. The  fact  you  are
  108. programming a program instead of the computer is of little consequence when you
  109. realize the RESULTS are the same.
  110.  
  111. YES YOU CAN program.  If you have used  DATAMAGE  to select a group of  records
  112. and  print  them you ALREADY HAVE! You have issued  a  first-class  programming
  113. command:   IF  (parameters   you  selected to form the group)  THEN  PRINT  THE
  114. RECORDS.  And you have, no doubt, met with  success in doing so.  So, the  hard
  115. part is behind you.
  116.  
  117. DATAMAGE, like the programming language of your choice,  consists of a  limited
  118. number of functions.  Many of the functions will do different, though  similar,
  119. operations when various parameters are specified.  Like a programmer, the  user
  120. selects  these functions and specifies parameters to them.   The functions  are
  121. building  blocks,   of  which a very great number of possible  process  can  be
  122. constructed.
  123.  
  124. Most  ways  to  program  group your   function   selections   into  a  program.
  125. DATAMAGE allows you the option of making a program:  The MACRO.
  126.  
  127. There's  DANGER  in MACROland. A poorly designed MACRO can work  well  for  six
  128. months or six years, then blow up in your face.   Leaving you with some of your
  129. records having been processed, some not, and no way to determine which is whom.
  130.  
  131. Let's say we have a customer file with records from all states.  Every so often
  132. we  need to print our receivables by state in order on amount.  While we're  at
  133. it, we'll post interest on the balance to the record.
  134.  
  135. A MACRO is written that selects records in the  target state,  selects  records
  136. in  the  survivors  having a balance, sorts on the balance,  prints  a  report,
  137. computes/adds  interest, etc.  Then reloads the file, and does it  again  until
  138. all  fifty  states  have been processed.  The   macro  is  carefully  verified,
  139. implemented, and runs fine for three  months.
  140.  
  141. The forth month all our customers in Montana are paid up. The MACRO expects  to
  142. find  Montana  records  to process but has found none.  If  this  had  happened
  143. during manual  program operation  DATAMAGE  would have provided the appropriate
  144. error  message,  and how to proceed  would then be left up to the user.   In  a
  145. MACRO that's not good enough.
  146.  
  147. If  the  MACRO aborts we are left in the sad situation  described  above.   The
  148. operator (whenever the MACRO is run) CAN NOT be counted upon to recover from an
  149. error  of  this  type.   So  the MACRO must  recover  the  error  and  continue
  150. processing the remainder of the states.
  151.  
  152. In  order  for the MACRO to recover it must  JUMP OVER  the  instructions  that
  153. compute  the Montana records, and resume processing with the first  instruction
  154. that  processes the records for the next state.
  155.  
  156. After  the  processing of each states' records the  entire  file  was  reloaded
  157. using the F11 function, then the F7 function was used to select the records  in
  158. the  next  state  to  be processed.  If the MACRO jumped to the  next  F11  the
  159. recovery would be successful.
  160.  
  161. The  above situation is often duplicated,  but a marker file is loaded  between
  162. the  processes. For that reason you may also select resume next load marker  as
  163. an  error  option.
  164.  
  165. In  some cases you would want a MACRO to end early if no survivors  were  found
  166. during a record select operation. The ABORT error option will do that, and  the
  167. message FATAL ERROR IN MACRO will be displayed.
  168.  
  169. Depending  on  the  complexity  of the task a  MACRO  may  or  may  not  be  an
  170. acceptable  way of doing it.  If you need, and can handle, the  kind  of  error
  171. trapping that allows you to redirect the control to any label you have  defined
  172. inside your program then get QUICK BASIC and write your own program.
  173.  
  174. If DATAMAGE  allowed that kind of  processing it would,  of necessity,  exclude
  175. many  users incapable of programming at that level.   In other words you  would
  176. have  to  be a programmer to be able to use the program.  And that's  NOT  what
  177. we're doing, here.
  178.  
  179. TIP #2: PLAN FOR THE UNEXPECTED!
  180.  
  181. Let's take the above example just a little further, if you can stand it....
  182.  
  183. Suppose we have current customers in only 31 states, but we have BIG PLANS!  By
  184. taking  advantage of out simulation environment we can write a macro that  will
  185. compute the states having no current customers.
  186.  
  187. Unlike  BASIC,  DATAMAGE  will not allow the processing of  data  that  is  not
  188. present.   In  BASIC  you would use a FOR-NEXT loop  structure,  and  an  array
  189. containing the two-letter state abbreviation for all 50 states.
  190.  
  191. The  FOR-NEXT would, first off, read through the file and identify the  records
  192. matching  the current state code.  If there were none you would BRANCH  to  the
  193. NEXT, and try the next state code.
  194.  
  195. Odds  are  you  don't  program  in BASIC (or  any  other  language)  and  don't
  196. understand the last two paragraphs.  That's OK. (Bunky); DATAMAGE was  written
  197. for YOU!
  198.  
  199. Simply  enter a couple of "dummy" records for the states in which you  have  no
  200. current  customers.   During MACRO recording the select records  routines  MUST
  201. find  some survivors.  If a select records operation is executed that finds  no
  202. survivors an error message will be displayed and the MACRO will be aborted.
  203.  
  204. When  your  MACRO is completed and verified copy it to the dir  containing  the
  205. real  file to be processed.  If you have correctly selected your error  options
  206. the MACRO will compute records in the states currently represented in the file,
  207. and ignore the fact that some are missing.
  208.  
  209. Suppose after our monster MACRO had finished its calculations we wanted a total
  210. of the money we charged our customers who owed us for doing nothing during  the
  211. preceding week/month etc.
  212.  
  213. That would be easy, just write it into the records as they were computed,  then
  214. re-load the file and use F14 to make a total, right?
  215.  
  216. And it would work OK. first trip....
  217.  
  218. Second  month/week,  the values from the last run would still be there.   If  a
  219. customer  was paid up it would still be added in, along with the new  data  for
  220. those who weren't paid up and had been processed....
  221.  
  222. And,  what  about  that cash and carry state: Montana?   The  records  accruing
  223. interest  last month would still have the amount of interest in them,  and  it,
  224. too, would be added to the would-be total of this months interest.
  225.  
  226. The  F9 function writes the same value to all records now in the group.  If  it
  227. was  used  to  zero the field containing the interest before  the  states  were
  228. selected and processed there would be no problem.
  229.  
  230. The  computer  can't think, and neither can your macro.   Neither  recognize  a
  231. logic error on your part, and both will hum happily along and feed you  garbage
  232. until you burst.
  233.  
  234. And  your  car  will happily slam into a concrete wall at 80.   The  reason  it
  235. doesn't is because you are in control, and you can think.  In the drive to work
  236. situation you are required to think, and since you made it I'll assume you did.
  237.  
  238. In order to drive the DATAMAGE successfully to your destination you may find it
  239. useful to think about your "trip" before you start.  You know that  "beantowne"
  240. is  somewhere  in the upper left corner of Texas.  So you access  Mr.  McNally,
  241. find it, then chart a course on roads that appear on the map.
  242.  
  243. TIP #3:  THINK ABOUT IT A WHILE FIRST!
  244.  
  245. Once  I worked for a place that had eight programmers.  And most of  them  came
  246. and went.  I stayed a while, though I hated the conditions, because I liked the
  247. work and the guy I worked for.
  248.  
  249. One  day  I asked him:  "When a new guy comes in, how do you tell if  he's  any
  250. good?"   His reply was that he just used his watch.  The time interval  between
  251. the new guy getting an assignment, and beginning to code it was the key.
  252.  
  253. Within  reason,  it was the longer the better, and the more questions  the  guy
  254. asked  in the time period, the better.  He also told me he didn't think  I  was
  255. any good, at first!  And that I was the only exception to his rule, to date.
  256.  
  257. "Yeah,  OK.,  that's  what I thought you wanted; just  made  sure."   was  his
  258. favorite  line,  and he NEVER had to re-organize a program to do  something  he
  259. forgot.  When changes were called for by the big-shots he often started over.
  260.  
  261. I had a way of coding that was so modular I could "throw it up in the air"  and
  262. when it landed it would do whatever else.  We learned from each other.
  263.  
  264. Organizational  methods/props  galore exist to provide  graphic  facsimiles  of
  265. program  control; some use flowcharts, some wiege boards, even dolls with  many
  266. pins.   Still  others ask their questions, then sit like the sphinx  for  three
  267. weeks before writing code that runs first time.
  268.  
  269. Anyhow,  the  WORST POSSIBLE way to do it is to run through it and  walk  away.
  270. You will find it has a way of calling you back, and installing grief.
  271.  
  272. TIP #4:  DON'T BYTE OFF MORE THAN YOU CAN CHEW!
  273.  
  274. Though  it may seem otherwise, the production of any serious  business  systems
  275. using  DATAMAGE  requires  of  the user/programmer the  same  things  that  are
  276. required  when using BASIC or C:  A thorough knowledge of the software AND  the
  277. job  to be done. Though the former has become a LOT easier, the latter  remains
  278. unchanged.
  279.  
  280. The  presence of a computer in the room frightens many people into  immobility.
  281. Others don't think logically, and computers require logic.  And some people are
  282. just plain dumb.
  283.  
  284. If you are a logical person who is unafraid, possessed of average intelligence,
  285. and  have taken the time to define and fully understand the job to be done  you
  286. will do well.
  287.  
  288. If not, you can get someone else to do it.  If you need to pay them then do so.
  289. That  is  far  more  economical than taking  action  on  erroneous  data.   And
  290. preferable  to the frustration experienced by those whose thought processes  do
  291. not lend themselves to computerized data processing.