home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / dbase / tn9010.arj / DIALOGUE.TXT next >
Text File  |  1991-03-05  |  19KB  |  427 lines

  1. Dialogue
  2. Questions and Answers
  3.  
  4. A Window By Any Other Name.
  5.  
  6. Q:              I am using an ON KEY LABEL in my program which I have active
  7. while using a screen form to edit records.  My screen form contains a
  8. memo window.  Pressing the ON KEY jumps to another work area, opens
  9. another database, and enters BROWSE mode.  Upon quitting the BROWSE, I
  10. return to the original work area.  The memo window is now a memo
  11. marker and an error message displays the message Window Not Defined. 
  12. What has happened?
  13.  
  14. A:              The Form.gen file, which is responsible for compiling your
  15. screen form, defines windows (for the memo window) to a default memory
  16. variable named window1.  Merely activating another format file in
  17. another work area with a memo window caused the second format file to
  18. also DEFINE WINDOW WINDOW1.  The second format file also does a
  19. DEACTIVATE WINDOW and RELEASE WINDOW WINDOW1 which eliminates the
  20. window defined by the first format file. 
  21.  
  22. It would be necessary in this case for you to modify the .fmt file of
  23. either of the two windows and change the name of one of the windows so
  24. they are not in conflict.
  25.  
  26. The Bottom Line
  27.  
  28. Q:              Why is it that Ctrl-Y does not work when I attempt to delete
  29. the last line in a band during my report design?
  30.  
  31. A:              Ctrl-Y was modified in version 1.1 for use in the MODIFY
  32. COMMAND editor where there existed a problem with the ability to
  33. physically delete the last line.  Correcting the problem there altered
  34. the functionality when editing bands in reports.  The workaround is to
  35. move the second-to-last line down using F6 Select and then deleting
  36. the now-blank second-to-last line.
  37.  
  38. Windows With (Status) Bars
  39.  
  40. Q:              After creating a screen form, I received the message Illegal
  41. Value when I attempted to display the data.  From the way the
  42. information displayed, it appears as if a memo window which I have
  43. toward the bottom of my screen is causing it.  How do I prevent the
  44. error?
  45.  
  46. A:              You will need to move the window up where it will not overlap
  47. the status bar.
  48.  
  49. While in the design screen, you might not realize that the memo window
  50. will overlap the status bar because dBASE IV displays the status bar
  51. two lines above the position it will ultimately appear at in the final
  52. screen form.  This is because the status bar always appears on line 22
  53. and the virtual screen of the form designer is positioned two lines
  54. lower than the actual screen (to allow for the Menu and Ruler).
  55.  
  56. If you place a memo as a marker on row 20 or 21, and then proceed to
  57. size the window from that upper-left position (row 20/21) to a
  58. lower-right position and the status bar is on, you will get the error
  59. message you saw when you try to display data using the screen form.  
  60. The window size will be truncated to accommodate the status bar. 
  61. However, the resulting window size will be too small and will cause
  62. the error message.
  63.  
  64. Summary Commands Don't Echo Anymore
  65.  
  66. Q:              I've made the switch from dBASE III PLUS to dBASE IV and
  67. everything has been pretty smooth with one exception.  I have programs
  68. that produce reports that were summarized with record counts that are
  69. no longer being printed.  It seems to me like the commands are either
  70. being ignored or some functionality has changed.  Could you shed some
  71. light on this?
  72.  
  73. A:              Actually, this is an issue that first presented itself when
  74. dBASE IV was originally introduced.  In dBASE III PLUS, SET PRINT ON
  75. gave printed results to commands like COUNT and SUM.  In dBASE IV, it
  76. is necessary to direct the result of a COUNT, SUM or AVERAGE statement
  77. to a memory variable.  Then use a syntax such as
  78.  
  79. ? <mvar> AT <column>
  80.  
  81. to print the result on the page.  Although this would appear to be a
  82. removal of functionality, all the summarizing features noted here are
  83. now directly implementable in a dBASE IV report.  The only reason
  84. COUNT and SUM statements appearing after REPORT FORM commands were
  85. implemented in this way is because there was no way to include them in
  86. the more limited dBASE III PLUS report generator.
  87.  
  88. High Resolution Error
  89.  
  90. Q:              While attempting to run a program I made with the Application
  91. Generator, the program was halted by an error referencing a variable
  92. called gn_error and the message said the variable was not found.  I
  93. did not create this variable.  What causes this error?
  94.  
  95. A:              There is a problem with Menu.gen when generating code for
  96. EGA43 video mode. The .prg file references the variable gn_error
  97. before it initializes it. This results in an error when you try to run
  98. the program that says Variable not found gn_error. The workaround is
  99. to avoid using 43 line mode when generating or, if 43 lines are
  100. required, modify the .prg file generated by the Applications Generator
  101. and comment out two IF structures near the beginning of the code. The
  102. first begins with 
  103.  
  104. IF gc_display <> "EGA43"
  105.  
  106. and the other is right after it and starts with 
  107.  
  108. IF gn_error <> 0
  109.  
  110. These two structures just make sure that the display mode was actually
  111. set to 43 line mode and give an error message if it couldn't set it.
  112. Commenting them out just removes this safety feature. 
  113.  
  114. QBE Takes Over the Show
  115.  
  116. Q:              I am developing an application where I want to give the users
  117. access to the QBE interface but do not wish for them to be able to
  118. change or update any records while in QBE.  I tried to USE the data
  119. file with the NOUPDATE qualification and then enter QBE to create the
  120. query.  When I press F2 to view the selected data, I am still able to
  121. edit it.  Since I can't trap the F2 key here, the situation looks
  122. bleak.  Have you any suggestions?
  123.  
  124. A:              The .qbe file is overwriting your preferences for NOUPDATE by
  125. opening any specified files again.  Try copying the code from the .qbe
  126. into a .prg file and executing the view as a program.  If the view is
  127. not complex (that is it does not CREATE, SORT, or INDEX but can USE,
  128. SET INDEX, SET FILTER and SET FIELDS), you can set this up as a .vue
  129. file that is still called from your program using SET VIEW TO. 
  130.  
  131. Print Menu Availability
  132.  
  133. Q:              When I start to print a report from the Control Center, I
  134. highlight the report name and press Enter.  The Print menu will
  135. appear.  I then go to the Print: Destination menu to select the
  136. printer I want to print with.  It's not actually a pop-up menu but
  137. more like a multiple choice list within a single window.  If you run
  138. the report from a .prg or the dot prompt, you don't get the Print
  139. menu.  Is there any way to activate it?
  140.  
  141. A:              No, sorry.  You can program a list of printer drivers into a
  142. pick list using the Application Generator without a lot of trouble.  A
  143. pick list in a popup can be used with the PROMPT FILES LIKE *.pr2
  144. option.  You also might try saving different drivers into different
  145. print form (.prf) files and name the .prf files so that they are
  146. easily associated with the different printers you have.  
  147.  
  148. If you're running from the dot prompt or a program and it is not
  149. necessary to give the user a choice, simply issue the command 
  150.  
  151. _pform = "<print form file name>.PRF"
  152.  
  153.  or  
  154.  
  155. _pdriver = "<printer driver name>" 
  156.  
  157. right before you run the report. 
  158.  
  159. Record Runaround
  160.  
  161. Q:              I'm using a name and address database and normally work from
  162. the dot prompt. After making an append and pressing Ctrl-End to save
  163. it, the record pointer always goes to the last record in the index.  I
  164. would like to be able to call a program to print some information from
  165. this newly appended record, but the record pointer does not follow
  166. it.  dBASE III did not work this way; it followed the new addition.   
  167.  
  168. A:              Under the Records menu is the option Follow record to new
  169. position. Change this to YES and the pointer should follow the record
  170. in the index. 
  171.  
  172. Macro File Swapping
  173.  
  174. Q:              I have an application wherein I can call several macros from
  175. an edit routine.  So many, in fact, that I need to be able to change
  176. macro files.  Is there a way I can do this without leaving the edit
  177. routine?
  178.  
  179. A:              By using ON KEY LABEL, you can call a UDF that could allow you
  180. to change macro files.  The ON KEY LABEL statement would appear in the
  181. setup portion of your program (or in a setup program that loads when
  182. you first begin a dBASE IV session).  The statement would appear as
  183.  
  184. ON KEY LABEL <label key> ? MacroChg()
  185.  
  186. The UDF would consist of a handful of statements like the following:
  187.  
  188. FUNCTION MacroChg
  189.                 ON ERROR DUMMY = ""
  190.                 DEFINE WINDOW Ask FROM 11,10 TO 13,70
  191.                 ACTIVATE WINDOW Ask
  192.                 RESTORE MACROS FROM
  193.                 DEACTIVATE WINDOW Ask
  194.                 RELEASE WINDOW Ask
  195.                 ON ERROR
  196.                 RELEASE DUMMY
  197. RETURN .T.
  198.  
  199. The ON ERROR routine is to avoid an error if you press Enter without
  200. entering a file name.  Conversely, this logic does not account for a
  201. file name entered which does not exist on the current drive and
  202. directory.  You may want to enhance the error checking in your actual
  203. program.  
  204.  
  205. By just using the command line RESTORE MACROS FROM, you are
  206. automatically given the prompt: Enter filename to restore from: in the
  207. activated window. Upon entering the filename, the window disappears
  208. and you return to your edit routine.
  209.  
  210. The Long and Winding Company Name
  211.  
  212. Q:              I have a mailing list of about 2,000 law firm names, many of
  213. which are so long they won't fit on one line of any type of label. 
  214. How can I get these long fields to wrap? 
  215.  
  216. A:              The "Vertical stretch" option in the label design screen is
  217. unavailable from the Fields menu.  Although you could modify the .lbg
  218. file to manually add the vertical stretch feature to the field(s) you
  219. prefer, this will cause problems in the printing of multi-column
  220. labels by way of unwanted blank lines.  Single column labels would be
  221. forced out of proper alignment as well.
  222.  
  223. Alternatively, you could make the company name field a calculated
  224. field which would tack on the acceptable Latin abbreviation et. al. 
  225. (and others) to a truncated company name.  This would require a UDF to
  226. analyze how many names could suitably fit on a line along with the
  227. appended abbreviation.  Here's a UDF to help you along:
  228.  
  229. FUNCTION EtAl
  230.                 PARAMETER mstring,mlength
  231.                 lc_talk = SET("TALK")
  232.                 SET TALK OFF
  233.  
  234.                 IF LEN(RTRIM(mstring)) > mlength
  235.                         maxlen = mlength-6  && the length of " et al."
  236.                         ctr = 1
  237.  
  238.                         IF "," $ SUBSTR(mstring, maxlen)
  239.                                 DO CASE
  240.                                         CASE SUBSTR(mstring,  maxlen, 1) =
  241. "&"  
  242.                                                 ctr = ctr + 2  
  243.  
  244.                                         CASE .NOT. SUBSTR(mstring, maxlen, 1)
  245. $ ","   
  246.                                                 DO WHILE
  247. SUBSTR(mstring,maxlen-ctr,1)<> ","
  248.                                                         ctr = ctr + 1
  249.                                                 ENDDO
  250.                                 ENDCASE
  251.                                 mstring = SUBSTR(mstring, 1, maxlen - ctr) + "
  252. et al." 
  253.                         ELSE
  254.                                 DO CASE
  255.                                         CASE AT("&", SUBSTR(mstring, 1,
  256. maxlen)) > 0
  257.                                                 mstring = LEFT(mstring,
  258. AT("&", ;
  259.                                                 SUBSTR(mstring, 1, maxlen)) -
  260. 2) +  " et al."
  261.  
  262.                                         CASE AT(" AND ",UPPER(SUBSTR(mstring,
  263. 1, maxlen))) > 0
  264.                                                 mstring = LEFT(mstring, AT("
  265. AND ",;
  266.                                                 UPPER(SUBSTR(mstring, 1,
  267. maxlen)))) + " et al."
  268.                                 ENDCASE
  269.                         ENDIF
  270.                 ENDIF
  271.                 SET TALK &lc_talk
  272. RETURN mstring 
  273.  
  274. In this function, the string of a field or variable is passed as the
  275. first parameter.  The second parameter is the desired maximum length
  276. of the string.  The function subtracts the spaces required for the et
  277. al. to be appended on to the end.  
  278.  
  279. The logic of this UDF assumes that company names are separated by
  280. commas and the word "and" or an & may precede the last name.  The
  281. logic will not accidentally break up double word last names (like Van
  282. Dyke and De Leon) and will not mistake the word "and" as a name. 
  283. Conversely, the logic ignores any string of characters containing the
  284. word "and" as it looks for spaces on each side of the three-letter
  285. sequence.
  286.  
  287. Try it on your long-winded field to see the results with this simple
  288. test:
  289.  
  290. LIST EtAl(<fieldname>, <number>)    
  291.  
  292. Indentation Frustration
  293.  
  294. Q:              I'm new at programming but I'm already learning how difficult
  295. it is to debug code without any indentation.  On long DO WHILE
  296. segments with nested IF and DO CASE clauses, it's easy to lose track
  297. of what clauses have been properly closed.  Does dBASE IV come with
  298. any type of code-formatting utility? 
  299.  
  300. A:              No, but they are available commercially and in shareware or in
  301. the public domain.  One utility that immediately comes to mind is
  302. SNAP, a Shareware "Documentor" that is available on the Ashton-Tate
  303. BBS. It documents and analyzes dBASE III PLUS, dBASE IV (including
  304. .mdx recognition,  but not SQL) with included support for most all of
  305. the popular libraries available.  Additionally, one may modify the
  306. keywords files to customize the program.  SNAP will re-indent your
  307. source code as well as create headings, action diagrams,
  308. cross-references, tree-structures and data dictionaries.  If you are
  309. interested, please download SNAP42D.zip from Files Library DBTOOLS on
  310. the Ashton-Tate BBS.  Since it is Shareware, the authors do appreciate
  311. a registration fee. 
  312.  
  313. Julian, When Are You?
  314.  
  315. Q:              I work for the government and we require dates to appear in a
  316. Julian-type format.  It is a 4 digit representation in which the first
  317. number is the number of the year of the decade (0-9) and the remaining
  318. three numbers represent the number of days since January 1st.  Is
  319. there any way to automatically calculate this with dBASE IV?
  320.  
  321. A:              No preset function exists for this type of calculation but you
  322. always have UDFs.  Try the one below:
  323.  
  324. FUNCTION Date2Jul
  325.                 PARAMETER j_date
  326.                 lc_talk = SET("TALK")
  327.                 SET TALK OFF
  328.  
  329.                 STORE " " TO mdate
  330.                 mdate = (VAL(RIGHT(j_date,3)) - 1) + CTOD("01/01/" + ;
  331.                         IIF(RIGHT(STR(YEAR(DATE())), 1) < LEFT(j_date, 1),
  332. "8", "9") + ;
  333.                         LEFT(j_date, 1))
  334.                 SET TALK &lc_talk
  335. RETURN mdate
  336.  
  337. Notice the IIF statement which contains a reference to a choice of "8"
  338. or "9" as a return result.    This implies that the function is
  339. capable of determining a Julian date within a two decade window for
  340. the remainder of the twentieth century.  
  341.  
  342. A reverse function would be exactly the same except the  variables
  343. j_date and mdate would be reversed.  j_date would be calculated as
  344. follows:
  345.  
  346. j_date = RIGHT(STR(YEAR(mdate)), 1) + RIGHT("000" + LTRIM(STR(mdate -
  347. ;
  348. CTOD("01/01/" + LTRIM(STR(YEAR(mdate)))) + 1)), 3)
  349.   That's the Way It Is, Period!
  350. Q:              I am trying to install dBASE IV version 1.1 to the root
  351. directory of a partitioned drive and I am having a difficult time
  352. doing so.  It seems that it does not create the overlay file, without
  353. which I can't even get into the program.  Is this a bug?
  354. A:              In the entomological sense of the word, definitely not.  But
  355. it may be something about as small as a flea that is causing the
  356. problem.  When prompted for the drive in which to install dBASE IV,
  357. enter the drive letter, followed by a colon, followed by a backslash
  358. and terminated with a period.  The added period prevents the Install
  359. program from adding an additional backslash.
  360. SCAN and Macro Substitution
  361. Q:              I have a program wherein I am using the new SCAN.ENDSCAN
  362. construct.  I wish to SCAN for a condition which uses macro
  363. substitution:
  364. SCAN FOR &mvar = "Smith"
  365. This is generating an error when I try to compile.  Is there any way
  366. around this limitation?
  367. A:              Thanks to the use of a UDF, you can sneak by the compiler and
  368. accomplish your task.  Create a UDF with the following command lines. 
  369. The UDF name and variable names are changeable to your specifications:
  370. FUNCTION IsMacro
  371.                 PARAMETER lc_field
  372. RETURN(&lc_field)
  373. Then, in your code, substitute the macro substitution reference as
  374. follows:
  375.  
  376. SCAN FOR IsMacro(<mvar name>) = "Smith"
  377.  
  378. The mvar name reference should not be in quotes.
  379.  
  380. Status Bar Information
  381.  
  382. Q:              Any idea why a deleted record would not show up on the status
  383. line?  I can issue the DELETE command from the dot prompt, I receive
  384. the notification 1 record deleted, but Del doesn't appear on the
  385. status line.  I've even issued the command  
  386.  
  387. ? DELETED()
  388.  
  389. which returns .T., so why no Del marker on the status line?
  390.  
  391. A:              The Del marker only appears on the status line in full screen
  392. commands  such as EDIT, BROWSE and APPEND when the record pointer is
  393. located on a deleted record.  
  394.  
  395. Preparing RunTime Distribution Disks
  396.  
  397. Q:              I am having trouble preparing distribution disks that my
  398. end-users can successfully install from.  Could you detail the
  399. procedure?
  400.  
  401. A:              The batch file Rinstall.bat calls a utility called Fsize.com
  402. which determines the type of disk being installed from (360K or
  403. other).   The other is important because, should the first RunTime
  404. disk be a 1.2 MB disk, then Rinstall expects its files to be arranged
  405. like a 31/2" diskette.  If the user wants to distribute  51/4" disks,
  406. then the first disk in the install must be formatted to 360K.  If 1.2
  407. MB  51/4" disks are to be distributed, the files must be setup so that
  408. they match a 31/2" configuration.   The configuration of files are
  409. shown below.
  410.  
  411. For 31/2" (or high density 5 1/4"), two disks are needed:
  412. Disk 1:
  413. RTime1.exe
  414. RTime2.exe
  415. RInstall.bat
  416. FSize.com
  417. Disk 2:
  418. RInstall.bat
  419. RTime3.exe
  420. For  51/4" (360K) disks, three disks are needed:
  421. Disk 1:
  422. RTime1.exe
  423. RInstall.bat
  424. FSize.com
  425.  
  426.  
  427.