home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / rbnotes2.zip / EDTORIAL.10 next >
Text File  |  1986-01-31  |  18KB  |  529 lines

  1. *********************************************************
  2. *   TECHNICAL EDITORIAL NUMBER 10 -- JANUARY 31, 1986   *
  3. *********************************************************
  4. Solutions and explanations for some commonly encountered problems.
  5.  
  6.  
  7. ===========================================================================
  8. RESETTING REPORT VARS
  9. ===========================================================================
  10. Product: R:base 5000 ver. 1.01
  11.  
  12. DESCRIPTION:  When I set up breakpoints in the R:base 5000 Report Writer, I 
  13. go into (M)ark mode and choose the (B)reak option and R:base asks me, "Do 
  14. you want to manually reset break variables[NO]?"
  15.  
  16. What does "manually reset" mean?  
  17.  
  18.  
  19. EXPLANATION:  The majority of customers are breaking on only one column and 
  20. do not need to even worry about this.  If you fall into this catagory, 
  21. press the [ENTER] key and ignore the question.  If breaking on more than 
  22. one column, read on.
  23.  
  24. If you press [ENTER] in response to this question, the default (NO) will be 
  25. used.  
  26.  
  27. In order to understand why you probably want to answer NO, you need to 
  28. understand the concepts of breaks, accumulators, and reset variables.
  29.  
  30. NO -- means you want variables that were reset in inner breaks to be 
  31. automatically reset in outer breaks.  In 99% of all cases you will want 
  32. this automatic resetting.
  33.  
  34. YES -- means you want to manually add inner break reset variables to the 
  35. reset list of the outer breaks.  This is usually not necessary.
  36.  
  37. If you are breaking on one column and then breaking on another column 
  38. "inside" the first, you have two levels of breaks.  Level one is the outer 
  39. break and level two is the inner break.  For example, you may wish to break 
  40. on COMPANY (the outer or level one break) and then break on DEPT within 
  41. COMPANY (the inner or level two break).  COMPANY and DEPT are the break 
  42. columns; they are NOT the reset variables.
  43.  
  44. Reset variables are the accumulators.  They are the variables that you want 
  45. to continue adding things up until a break is encountered.  At break time 
  46. you want the reset variables to be reset to zero.  Reset variables are 
  47. defined in the (D)efine mode of the Report Writer just like any other 
  48. report variable.  You might want, for example, to add up all expenses by 
  49. COMPANY and by DEPT within COMPANY.  You will need to set up reset 
  50. variables for each break.  For example,
  51.  
  52. 1.  In (D)efine mode set up two report variables (CO-EXP and DEPT-EXP) to 
  53.     accumulate the EXPENSE column for each break column:
  54.  
  55.     CO-EXP = CO-EXP + EXPENSE
  56.     DEPT-EXP = DEPT-EXP + EXPENSEwh
  57.  
  58. 2.  Now, when in (M)ark mode:
  59.  
  60.     If reset variables are automatically reset (that is you answered NO to 
  61.     the question), you need to add CO-EXP to the reset list for the COMPANY 
  62.     break and you need to add DEPT-EXP to the reset list for the DEPT 
  63.     break.  DEPT-EXP will automatically be reset when either COMPANY or 
  64.     DEPT breaks.
  65.  
  66.     If reset variables are manually reset (that is you answered YES to the 
  67.     question), you need to add both CO-EXP and DEPT-EXP to the reset list 
  68.     for the COMPANY break and DEPT-EXP to the reset list for the DEPT 
  69.     break.  If you do not manually enter DEPT-EXP to the reset list for the 
  70.     COMPANY break, under this option, it will not be reset when a new 
  71.     COMPANY is encountered.
  72.  
  73.  
  74. SOLUTION:  It is best to allow the computer to automatically reset inner 
  75. breaks' reset variables when outer breaks occur by answering NO to the 
  76. question, "Do you want to manually reset break variables".
  77.  
  78. AUTOMATIC RESETTING (ANSWER NO):
  79. -------------------------------
  80. BREAK ONE - RESET LIST
  81.       var1
  82.  
  83.   BREAK TWO - RESET LIST
  84.         var2
  85.  
  86.     BREAK THREE - RESET LIST
  87.           var3
  88.  
  89.       BREAK FOUR - RESET LIST
  90.             var4
  91.  
  92. MANUAL RESETTING (ANSWER YES):
  93. -----------------------------
  94. BREAK ONE - RESET LIST
  95.       var1
  96.       var2
  97.       var3
  98.       var4
  99.  
  100.   BREAK TWO - RESET LIST
  101.         var2
  102.         var3
  103.         var4
  104.  
  105.     BREAK THREE - RESET LIST
  106.           var3
  107.           var4
  108.  
  109.       BREAK FOUR - RESET LIST
  110.             var4
  111.  
  112.  
  113.  
  114.  
  115.  
  116. ===========================================================================
  117. COMMAS IN INTEGERS 
  118. ===========================================================================
  119. Product: R:base 5000
  120. Versions 1.0, 1.01
  121.  
  122. DESCRIPTION:  I want my integer column NUMBER to print out on my report 
  123. with commas in every third (from the right) position. How do I do it? 
  124.  
  125.  
  126. SOLUTION:  Using the (d)efine option in reports, set up an expression like 
  127. the following:
  128.  
  129. REPVAR = NUMBER X $1.00
  130.  
  131. When you multiply by $1.00, REPVAR becomes a dollar variable.  Now, 
  132. (l)ocate REPVAR on the report instead of NUMBER and set DOLLAR to blank 
  133. before printing the report.  This method will print an extra .00 on the end 
  134. of every integer value, but it will put the commas in.  
  135.  
  136. If it is absolutely necessary to get rid of the .00s and your report only 
  137. has to go to the screen, you can blank out the .00 by locating a BLANK 
  138. report variable that has three ALT 255s in it on the same line in the last 
  139. three positions.  For instructions on how to do this, see page 7 of the 
  140. September 1985 R:base EXCHANGE.  
  141.  
  142. However, keep in mind that although ALT 255s are blanks to you, they are 
  143. gremlins to your printer.  If you need your report printed, it is best to 
  144. print it to a file with the .00s and then do a global search and replace 
  145. (with your word processor) to change the .00 to three blanks before 
  146. printing the report on the printer.
  147.  
  148.  
  149.  
  150.  
  151. ===========================================================================
  152. PRINTER GREMLINS
  153. ===========================================================================
  154. Product: R:base 5000
  155. version 1.0, 1.01 
  156.  
  157. DESCRIPTION:  I have gremlins in my printer!!  I keep encountering the 
  158. following problems:
  159.  
  160. o  My report is crooked, everything jumps to the left on some rows but not 
  161.    on others.  Printing to the screen is fine.
  162. o  Sometimes the wrong number is printed on the paper.  But if I print the 
  163.    report to the screen or to a file, the number is correct.
  164. o  I get a spurious form feed in the middle of the report with some 
  165.    printers.
  166.  
  167. Why is this happening?  
  168.  
  169.  
  170. EXPLANATION:  ALT 255s in your data, or in report variables, or in global 
  171. variables, or in the body of your report are the most likely culprits.  
  172. Most printers cannot handle an ALT 255.  An ALT 255 looks like a blank to 
  173. you and the screen has no problem with it so everything looks fine on the 
  174. screen.
  175.  
  176. How did ALT 255s get in there?
  177.  
  178. o  You may have entered it by holding down the ALT key and pressing 255 on 
  179.    the number pad. 
  180.  
  181. o  The computer may have put it into a column in your table that was 
  182.    supposed to be NULL if you loaded variables using the LOAD command (a 
  183.    common procedure with variable forms) and forgot to first issue the   
  184.    following command:
  185.  
  186.    SET NULL -0-.  
  187.  
  188.    If NULL was set to a blank and some of your TEXT variables were NULL you 
  189.    may have an ALT 255 in your data.  
  190.  
  191. o  If the column being loaded had been any of the other datatypes (DATE, 
  192.    TIME, INTEGER, DOLLAR, or REAL), and your operator pressed [ENTER] 
  193.    (because there was no entry), and NULL was not set to -0- before the 
  194.    LOAD block, then the entire row was probably not even added to the 
  195.    table.  You would not even know it if BELL and ERROR MESSAGES had been 
  196.    set off.  It is crucial to have NULL set to -0- before a LOAD command is 
  197.    executed.  Otherwise, later you may think that the data you entered 
  198.    disappeared, when in fact it was never loaded in the first place.
  199.  
  200.  
  201. SOLUTION:  First, fix the LOAD block in your R:base 5000 program code to 
  202. set NULL to -0- prior to executing the LOAD block.  Set it back to a blank 
  203. after the LOAD block and everything will look the same to the operator.  
  204. The following code will accomplish this task:
  205.  
  206. SET NULL -0-
  207. LOAD tblname
  208. .var1  .var2  .var3 
  209. END
  210. SET NULL " "
  211.  
  212. Next, get the gremlins out of your data with the following commands: 
  213.  
  214. SET NULL -0-
  215. CHANGE colname TO -0- WHERE COLNAME EQ " "  
  216. *(ALT 255 between the quotes on above line.
  217.   To enter it:  hold ALT key down, enter 255 on
  218.   number pad, release ALT key.)
  219.  
  220. Next, check and make sure that all the rows you have entered are actually 
  221. in the database.  
  222.  
  223. Finally, get the gremlins out of your reports by redefining any variables 
  224. that have been set to an ALT 255.  Set them to the type of blanks made by 
  225. the spacebar on your keyboard and you will not have any more problems.
  226.  
  227.  
  228.  
  229.  
  230. ===========================================================================
  231. TURNING TYPE-AHEAD ON
  232. ===========================================================================
  233. Product: R:base 5000
  234. versions 1.0, 1.01
  235.  
  236. DESCRIPTION:  I want the user to be able to type ahead while the command 
  237. file is processing, how do I do it?
  238.  
  239. SOLUTION:  Put the following command line into your command file:
  240.  
  241. SET ESCAPE OFF 
  242.  
  243. This command turns off the ability to escape processing while in the middle 
  244. of command file, WHILE loops, and database access.  With escape set off you 
  245. will not get the message "Press [Esc] to abort, any other key to continue".  
  246. Therefore, you can type ahead (until you have filled the buffer) while the 
  247. command file continues to process.
  248.  
  249.  
  250.  
  251.  
  252. **********************
  253. *    APPLICATIONS    *
  254. **********************
  255.  
  256.  
  257.  
  258. *******************
  259. COUNTING THE BREAKS
  260. *******************
  261. Product: R:base 5000
  262. versions 1.0, 1.01
  263.  
  264. any people want an easy way to count the number of breaks in a particular 
  265. report without having to do a TALLY.  In other words you want to break on 
  266. PROJECT# and you want the report to determine how many total projects there 
  267. were so you can put some averages and other statistics into your report. 
  268.  
  269. For example, consider a simple job costing application for a labor 
  270. intensive business like consulting.  This application has two tables:
  271.  
  272. JOBCOST table (transactions)
  273. --------------------------
  274. WORKDAY     DATE
  275. PROJ#       INTEGER 
  276. EMPLOYEE#   INTEGER 
  277. HOURS       REAL
  278.  
  279. PROJECTS table (master)
  280. -----------------------
  281. PROJ#       INTEGER
  282. PROJNAME    TEXT    40
  283. COMPANY     TEXT    30
  284. ADDR        TEXT    30
  285. CITY        TEXT    20
  286. STATE       TEXT    2
  287. ZIP         TEXT    5
  288.  
  289. When a project contract is signed, a new entry is made to the PROJECTS 
  290. table.  Every workday each of the employees charges hours to the various 
  291. projects that they worked on.  Now you want to print a report for the 
  292. period 12/1/85 through 12/31/85 that includes the following information:
  293.  
  294. o  Number of projects worked on during the month
  295. o  Average number of hours per project (total hours charged / total number 
  296.    of projects)
  297.  
  298. To do these statistics we need to know how many projects are included in 
  299. the report.  We cannot do a simple COMPUTE varname AS COUNT... because each 
  300. project number is duplicated many times in the JOBCOST table and we want to 
  301. count only the number of unique project numbers for the reporting period.  
  302.  
  303. We could do it by using the TALLY command with the appropriate WHERE 
  304. clause, sending the output to a file, loading the file into a temporary 
  305. table, and then counting the rows of the table.  But, thank goodness, all 
  306. that is not necessary!
  307.  
  308. You can count the number of breaks inside the report writer with a simple 
  309. trick shot.  
  310.  
  311. First, you need three variables: COUNTER, BREAKER, and TOT.  
  312.  
  313. Increment COUNTER by one for each row and add COUNTER to the reset list for 
  314. the break column (PROJ# in this example).  
  315.  
  316. Set BREAKER to 1 divided by COUNTER (BREAKER = 1 / COUNTER) and make sure 
  317. the datatype for BREAKER is INTEGER so any fraction will evaluate as zero.  
  318.  
  319. Since COUNTER will only be one at break time (it will be a larger number, 
  320. such as 2, 3, etc. at other times), the variable BREAKER will be 1 only at 
  321. break time.  At all other times, BREAKER will be zero because it will be a 
  322. fraction forced into an integer result.  
  323.  
  324. Therefore, the variable TOT can be used to accumulate the BREAKER variable 
  325. with the final result being the total number of breaks (that is, the total 
  326. number of unique values for the break column) in this report.
  327.  
  328. The variable expression definitions for the PROJ# example will look like 
  329. this.
  330.  
  331. 1:INTEGER : COUNTER  = COUNTER + 1
  332. 2:INTEGER : BREAKER  = 1 / COUNTER
  333. 3:INTEGER : TOT      = TOT + BREAKER
  334.  
  335. Now the variable TOT is the total number of projects.  To get the overall 
  336. average number of hours per project, add the following variable definition:
  337.  
  338. 4:REAL    : TOTHRS   = TOTHRS + HOURS 
  339.  
  340. where HOURS is the column in the table that contains the actual hours 
  341. charged to a project. 
  342.  
  343. Finally, compute the GRANDAVG with the following variable definition and 
  344. locate GRANDAVG in the report footer so it will print only once.
  345.  
  346. 5:REAL    : GRANDAVG = TOTHRS / TOT
  347.  
  348. Now, the following R:base command can print the statistics you want.
  349.  
  350. PRINT rptname WHERE WORKDAY GE +
  351. 12/1/85 AND WORKDAY LE 12/31/85. 
  352.  
  353. There are hundreds of applications where you could effectively use this 
  354. trick shot.  For another example, the following report counts the number of 
  355. unique accounts reported in order to report an average dollar amount per 
  356. account.
  357.  
  358. Account # ->      101
  359. Transaction Date   Amount
  360. ----------------   ------
  361. 01/01/85          $100.00
  362. 01/10/85            $5.00
  363. 01/15/85          $127.00
  364. 01/25/85          $139.00
  365. 01/31/85          $300.00
  366.                 ---------
  367.         total:    $671.00
  368.  
  369. -------------------------
  370.  
  371. Account # ->      222
  372. Transaction Date   Amount
  373. ----------------   ------
  374. 01/20/85           $35.00
  375. 02/02/85          $890.00
  376. 02/05/85          $287.00
  377. 04/09/85          $348.00
  378. 04/10/85          $761.00
  379. 04/21/85          $501.00
  380. 04/22/85           $10.00
  381.                 ---------
  382.         total:  $2,832.00
  383.  
  384. -------------------------
  385.  
  386. Account # ->      437
  387. Transaction Date   Amount
  388. ----------------   ------
  389. 01/01/85              
  390. 01/10/85          $100.00
  391. 01/27/85          $200.00
  392.                 ---------
  393.         total:    $300.00
  394.  
  395. =========================
  396. A. Total Accts:         3
  397. B. Total:       $3,803.00
  398. C. Average B/A: $1,267.67    
  399. =========================
  400.  
  401.  
  402.  
  403. ******************
  404. DAY OF WEEK FINDER
  405. ******************
  406. Product: R:base 5000 
  407. version 1.0, 1.01
  408.  
  409. Use this "function" macro WEEKDAY.CMD to find the day of the week for any 
  410. date. 
  411.  
  412. To run WEEKDAY.CMD, issue the following command line (this example uses 
  413. 12/25/85, but you can pass any date in): 
  414.  
  415. RUN WEEKDAY.CMD USING 12/25/85
  416.  
  417. When finished processing, the day of the week for 12/25/85 will be stored 
  418. in the global variable DAYFIND. 
  419.  
  420. The code for WEEKDAY.CMD is listed below.  This macro makes use of modular 
  421. math and provides a good example of stacking IF blocks and using the 
  422. asterisk wildcard.  
  423.  
  424. *( WEEKDAY.CMD)
  425. SET VAR frstdate TO 01/01/01
  426. LABEL top
  427. SET VAR diff REAL
  428. NEWPAGE
  429. SET VAR finddate TO .%1 
  430. SET VAR diff TO +
  431. .finddate - .frstdate
  432.  
  433. IF diff LT 0 THEN
  434. WRITE "Sorry, has to be +
  435. later than " AT 9 10
  436. SHOW VAR frstdate AT 9 38
  437. GOTO TOP
  438. ENDIF
  439.  
  440. SET VAR diff TO .diff / 7
  441. SET VAR diff TEXT
  442.  
  443. IF diff EQ "*.0*" THEN
  444. SET VAR dayfind TO "Tuesday"
  445. ENDIF
  446.  
  447. IF diff EQ "*.1*" THEN
  448. SET VAR dayfind TO "Wednesday"
  449. ENDIF
  450.  
  451. IF diff EQ "*.2*" THEN
  452. SET VAR dayfind TO "Thursday"
  453. ENDIF
  454.  
  455. IF diff EQ "*.4*" THEN
  456. SET VAR dayfind TO "Friday"
  457. ENDIF
  458.  
  459. IF diff EQ "*.5*" THEN
  460. SET VAR dayfind TO "Saturday"
  461. ENDIF
  462.  
  463. IF diff EQ "*.7*" THEN
  464. SET VAR dayfind TO "Sunday"
  465. ENDIF
  466.  
  467. IF diff EQ "*.8*" THEN
  468. SET VAR dayfind TO "Monday"
  469. ENDIF
  470.  
  471. WRITE "Day-of-week was/is: " +
  472. AT 10 10
  473. SHOW VAR dayfind AT 10 38
  474.  
  475.  
  476.  
  477.  
  478. *************
  479. CREDITS, ETC.
  480. *************
  481.  
  482.  
  483. PUBLICATION INFORMATION
  484. Microrim BBS Technical Editorials are published twice a month by Microrim, 
  485. Inc.  (206) 641-6619.  All inquiries, responses to this BBS Technical 
  486. Editorial, and contributions should be addressed to Kay D. Dayss, BBS 
  487. Technical Editorials Editor, Microrim, Inc., 3380 - 146th Pl. SE, Bellevue, 
  488. WA  98007.
  489.  
  490. ACKNOWLEDGEMENTS
  491. The following Microrim employees contributed programs, concepts, and/or 
  492. articles for this Technical Editorial:
  493.  
  494. Kelly Cline
  495. Marva Dasef
  496. Kay Dayss
  497.  
  498.  
  499. COPYRIGHT
  500. Copyright (c) 1986 by Microrim, Inc.  All rights reserved.  No part of this 
  501. publication may be reproduced, transmitted, transcribed, stored in a 
  502. retrieval system, or translated into any language in any form by any means, 
  503. without the written permission of Microrim, Inc.  
  504.  
  505.  
  506. TRADEMARK
  507. R:base is a registered trademark of Microrim, Inc.
  508. MICRORIM is a registered trademark of Microrim, Inc.
  509. R:BASE SERIES is a trademark of Microrim, Inc.
  510. Application EXPRESS is a trademark of Microrim, Inc.
  511. FileGateway is a trademark of Microrim, Inc.
  512. CLOUT is a registered trademark of Microrim, Inc.
  513. XRW is a trademark of Microrim, Inc.
  514. IBM is a registered trademark of International Business Machines Corp.
  515. PC XT and AT are trademarks of International Business Machines Corp.
  516. PC DOS is a trademark of Internation Business Machines Corp.
  517.  
  518.  
  519. DISCLAIMER
  520. Microrim, Inc., makes no representation or warranties with respect to the 
  521. contents hereof, and specifically disclaims any implied warranties of 
  522. merchantability or fitness for any particular purpose.  Further, Microrim, 
  523. Inc., reserves the right to revise this publication and to make changes in 
  524. the content hereof without obligation to notify any person of such revision 
  525. or change and shall not be liable for errors contained herein or for 
  526. incidental or consequential damages in connection with the furnishing, 
  527. performance, or use of this material.
  528.  
  529.