home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
dbase
/
tn9010.arj
/
DIALOGUE.TXT
next >
Wrap
Text File
|
1991-03-05
|
19KB
|
427 lines
Dialogue
Questions and Answers
A Window By Any Other Name.
Q: I am using an ON KEY LABEL in my program which I have active
while using a screen form to edit records. My screen form contains a
memo window. Pressing the ON KEY jumps to another work area, opens
another database, and enters BROWSE mode. Upon quitting the BROWSE, I
return to the original work area. The memo window is now a memo
marker and an error message displays the message Window Not Defined.
What has happened?
A: The Form.gen file, which is responsible for compiling your
screen form, defines windows (for the memo window) to a default memory
variable named window1. Merely activating another format file in
another work area with a memo window caused the second format file to
also DEFINE WINDOW WINDOW1. The second format file also does a
DEACTIVATE WINDOW and RELEASE WINDOW WINDOW1 which eliminates the
window defined by the first format file.
It would be necessary in this case for you to modify the .fmt file of
either of the two windows and change the name of one of the windows so
they are not in conflict.
The Bottom Line
Q: Why is it that Ctrl-Y does not work when I attempt to delete
the last line in a band during my report design?
A: Ctrl-Y was modified in version 1.1 for use in the MODIFY
COMMAND editor where there existed a problem with the ability to
physically delete the last line. Correcting the problem there altered
the functionality when editing bands in reports. The workaround is to
move the second-to-last line down using F6 Select and then deleting
the now-blank second-to-last line.
Windows With (Status) Bars
Q: After creating a screen form, I received the message Illegal
Value when I attempted to display the data. From the way the
information displayed, it appears as if a memo window which I have
toward the bottom of my screen is causing it. How do I prevent the
error?
A: You will need to move the window up where it will not overlap
the status bar.
While in the design screen, you might not realize that the memo window
will overlap the status bar because dBASE IV displays the status bar
two lines above the position it will ultimately appear at in the final
screen form. This is because the status bar always appears on line 22
and the virtual screen of the form designer is positioned two lines
lower than the actual screen (to allow for the Menu and Ruler).
If you place a memo as a marker on row 20 or 21, and then proceed to
size the window from that upper-left position (row 20/21) to a
lower-right position and the status bar is on, you will get the error
message you saw when you try to display data using the screen form.
The window size will be truncated to accommodate the status bar.
However, the resulting window size will be too small and will cause
the error message.
Summary Commands Don't Echo Anymore
Q: I've made the switch from dBASE III PLUS to dBASE IV and
everything has been pretty smooth with one exception. I have programs
that produce reports that were summarized with record counts that are
no longer being printed. It seems to me like the commands are either
being ignored or some functionality has changed. Could you shed some
light on this?
A: Actually, this is an issue that first presented itself when
dBASE IV was originally introduced. In dBASE III PLUS, SET PRINT ON
gave printed results to commands like COUNT and SUM. In dBASE IV, it
is necessary to direct the result of a COUNT, SUM or AVERAGE statement
to a memory variable. Then use a syntax such as
? <mvar> AT <column>
to print the result on the page. Although this would appear to be a
removal of functionality, all the summarizing features noted here are
now directly implementable in a dBASE IV report. The only reason
COUNT and SUM statements appearing after REPORT FORM commands were
implemented in this way is because there was no way to include them in
the more limited dBASE III PLUS report generator.
High Resolution Error
Q: While attempting to run a program I made with the Application
Generator, the program was halted by an error referencing a variable
called gn_error and the message said the variable was not found. I
did not create this variable. What causes this error?
A: There is a problem with Menu.gen when generating code for
EGA43 video mode. The .prg file references the variable gn_error
before it initializes it. This results in an error when you try to run
the program that says Variable not found gn_error. The workaround is
to avoid using 43 line mode when generating or, if 43 lines are
required, modify the .prg file generated by the Applications Generator
and comment out two IF structures near the beginning of the code. The
first begins with
IF gc_display <> "EGA43"
and the other is right after it and starts with
IF gn_error <> 0
These two structures just make sure that the display mode was actually
set to 43 line mode and give an error message if it couldn't set it.
Commenting them out just removes this safety feature.
QBE Takes Over the Show
Q: I am developing an application where I want to give the users
access to the QBE interface but do not wish for them to be able to
change or update any records while in QBE. I tried to USE the data
file with the NOUPDATE qualification and then enter QBE to create the
query. When I press F2 to view the selected data, I am still able to
edit it. Since I can't trap the F2 key here, the situation looks
bleak. Have you any suggestions?
A: The .qbe file is overwriting your preferences for NOUPDATE by
opening any specified files again. Try copying the code from the .qbe
into a .prg file and executing the view as a program. If the view is
not complex (that is it does not CREATE, SORT, or INDEX but can USE,
SET INDEX, SET FILTER and SET FIELDS), you can set this up as a .vue
file that is still called from your program using SET VIEW TO.
Print Menu Availability
Q: When I start to print a report from the Control Center, I
highlight the report name and press Enter. The Print menu will
appear. I then go to the Print: Destination menu to select the
printer I want to print with. It's not actually a pop-up menu but
more like a multiple choice list within a single window. If you run
the report from a .prg or the dot prompt, you don't get the Print
menu. Is there any way to activate it?
A: No, sorry. You can program a list of printer drivers into a
pick list using the Application Generator without a lot of trouble. A
pick list in a popup can be used with the PROMPT FILES LIKE *.pr2
option. You also might try saving different drivers into different
print form (.prf) files and name the .prf files so that they are
easily associated with the different printers you have.
If you're running from the dot prompt or a program and it is not
necessary to give the user a choice, simply issue the command
_pform = "<print form file name>.PRF"
or
_pdriver = "<printer driver name>"
right before you run the report.
Record Runaround
Q: I'm using a name and address database and normally work from
the dot prompt. After making an append and pressing Ctrl-End to save
it, the record pointer always goes to the last record in the index. I
would like to be able to call a program to print some information from
this newly appended record, but the record pointer does not follow
it. dBASE III did not work this way; it followed the new addition.
A: Under the Records menu is the option Follow record to new
position. Change this to YES and the pointer should follow the record
in the index.
Macro File Swapping
Q: I have an application wherein I can call several macros from
an edit routine. So many, in fact, that I need to be able to change
macro files. Is there a way I can do this without leaving the edit
routine?
A: By using ON KEY LABEL, you can call a UDF that could allow you
to change macro files. The ON KEY LABEL statement would appear in the
setup portion of your program (or in a setup program that loads when
you first begin a dBASE IV session). The statement would appear as
ON KEY LABEL <label key> ? MacroChg()
The UDF would consist of a handful of statements like the following:
FUNCTION MacroChg
ON ERROR DUMMY = ""
DEFINE WINDOW Ask FROM 11,10 TO 13,70
ACTIVATE WINDOW Ask
RESTORE MACROS FROM
DEACTIVATE WINDOW Ask
RELEASE WINDOW Ask
ON ERROR
RELEASE DUMMY
RETURN .T.
The ON ERROR routine is to avoid an error if you press Enter without
entering a file name. Conversely, this logic does not account for a
file name entered which does not exist on the current drive and
directory. You may want to enhance the error checking in your actual
program.
By just using the command line RESTORE MACROS FROM, you are
automatically given the prompt: Enter filename to restore from: in the
activated window. Upon entering the filename, the window disappears
and you return to your edit routine.
The Long and Winding Company Name
Q: I have a mailing list of about 2,000 law firm names, many of
which are so long they won't fit on one line of any type of label.
How can I get these long fields to wrap?
A: The "Vertical stretch" option in the label design screen is
unavailable from the Fields menu. Although you could modify the .lbg
file to manually add the vertical stretch feature to the field(s) you
prefer, this will cause problems in the printing of multi-column
labels by way of unwanted blank lines. Single column labels would be
forced out of proper alignment as well.
Alternatively, you could make the company name field a calculated
field which would tack on the acceptable Latin abbreviation et. al.
(and others) to a truncated company name. This would require a UDF to
analyze how many names could suitably fit on a line along with the
appended abbreviation. Here's a UDF to help you along:
FUNCTION EtAl
PARAMETER mstring,mlength
lc_talk = SET("TALK")
SET TALK OFF
IF LEN(RTRIM(mstring)) > mlength
maxlen = mlength-6 && the length of " et al."
ctr = 1
IF "," $ SUBSTR(mstring, maxlen)
DO CASE
CASE SUBSTR(mstring, maxlen, 1) =
"&"
ctr = ctr + 2
CASE .NOT. SUBSTR(mstring, maxlen, 1)
$ ","
DO WHILE
SUBSTR(mstring,maxlen-ctr,1)<> ","
ctr = ctr + 1
ENDDO
ENDCASE
mstring = SUBSTR(mstring, 1, maxlen - ctr) + "
et al."
ELSE
DO CASE
CASE AT("&", SUBSTR(mstring, 1,
maxlen)) > 0
mstring = LEFT(mstring,
AT("&", ;
SUBSTR(mstring, 1, maxlen)) -
2) + " et al."
CASE AT(" AND ",UPPER(SUBSTR(mstring,
1, maxlen))) > 0
mstring = LEFT(mstring, AT("
AND ",;
UPPER(SUBSTR(mstring, 1,
maxlen)))) + " et al."
ENDCASE
ENDIF
ENDIF
SET TALK &lc_talk
RETURN mstring
In this function, the string of a field or variable is passed as the
first parameter. The second parameter is the desired maximum length
of the string. The function subtracts the spaces required for the et
al. to be appended on to the end.
The logic of this UDF assumes that company names are separated by
commas and the word "and" or an & may precede the last name. The
logic will not accidentally break up double word last names (like Van
Dyke and De Leon) and will not mistake the word "and" as a name.
Conversely, the logic ignores any string of characters containing the
word "and" as it looks for spaces on each side of the three-letter
sequence.
Try it on your long-winded field to see the results with this simple
test:
LIST EtAl(<fieldname>, <number>)
Indentation Frustration
Q: I'm new at programming but I'm already learning how difficult
it is to debug code without any indentation. On long DO WHILE
segments with nested IF and DO CASE clauses, it's easy to lose track
of what clauses have been properly closed. Does dBASE IV come with
any type of code-formatting utility?
A: No, but they are available commercially and in shareware or in
the public domain. One utility that immediately comes to mind is
SNAP, a Shareware "Documentor" that is available on the Ashton-Tate
BBS. It documents and analyzes dBASE III PLUS, dBASE IV (including
.mdx recognition, but not SQL) with included support for most all of
the popular libraries available. Additionally, one may modify the
keywords files to customize the program. SNAP will re-indent your
source code as well as create headings, action diagrams,
cross-references, tree-structures and data dictionaries. If you are
interested, please download SNAP42D.zip from Files Library DBTOOLS on
the Ashton-Tate BBS. Since it is Shareware, the authors do appreciate
a registration fee.
Julian, When Are You?
Q: I work for the government and we require dates to appear in a
Julian-type format. It is a 4 digit representation in which the first
number is the number of the year of the decade (0-9) and the remaining
three numbers represent the number of days since January 1st. Is
there any way to automatically calculate this with dBASE IV?
A: No preset function exists for this type of calculation but you
always have UDFs. Try the one below:
FUNCTION Date2Jul
PARAMETER j_date
lc_talk = SET("TALK")
SET TALK OFF
STORE " " TO mdate
mdate = (VAL(RIGHT(j_date,3)) - 1) + CTOD("01/01/" + ;
IIF(RIGHT(STR(YEAR(DATE())), 1) < LEFT(j_date, 1),
"8", "9") + ;
LEFT(j_date, 1))
SET TALK &lc_talk
RETURN mdate
Notice the IIF statement which contains a reference to a choice of "8"
or "9" as a return result. This implies that the function is
capable of determining a Julian date within a two decade window for
the remainder of the twentieth century.
A reverse function would be exactly the same except the variables
j_date and mdate would be reversed. j_date would be calculated as
follows:
j_date = RIGHT(STR(YEAR(mdate)), 1) + RIGHT("000" + LTRIM(STR(mdate -
;
CTOD("01/01/" + LTRIM(STR(YEAR(mdate)))) + 1)), 3)
That's the Way It Is, Period!
Q: I am trying to install dBASE IV version 1.1 to the root
directory of a partitioned drive and I am having a difficult time
doing so. It seems that it does not create the overlay file, without
which I can't even get into the program. Is this a bug?
A: In the entomological sense of the word, definitely not. But
it may be something about as small as a flea that is causing the
problem. When prompted for the drive in which to install dBASE IV,
enter the drive letter, followed by a colon, followed by a backslash
and terminated with a period. The added period prevents the Install
program from adding an additional backslash.
SCAN and Macro Substitution
Q: I have a program wherein I am using the new SCAN.ENDSCAN
construct. I wish to SCAN for a condition which uses macro
substitution:
SCAN FOR &mvar = "Smith"
This is generating an error when I try to compile. Is there any way
around this limitation?
A: Thanks to the use of a UDF, you can sneak by the compiler and
accomplish your task. Create a UDF with the following command lines.
The UDF name and variable names are changeable to your specifications:
FUNCTION IsMacro
PARAMETER lc_field
RETURN(&lc_field)
Then, in your code, substitute the macro substitution reference as
follows:
SCAN FOR IsMacro(<mvar name>) = "Smith"
The mvar name reference should not be in quotes.
Status Bar Information
Q: Any idea why a deleted record would not show up on the status
line? I can issue the DELETE command from the dot prompt, I receive
the notification 1 record deleted, but Del doesn't appear on the
status line. I've even issued the command
? DELETED()
which returns .T., so why no Del marker on the status line?
A: The Del marker only appears on the status line in full screen
commands such as EDIT, BROWSE and APPEND when the record pointer is
located on a deleted record.
Preparing RunTime Distribution Disks
Q: I am having trouble preparing distribution disks that my
end-users can successfully install from. Could you detail the
procedure?
A: The batch file Rinstall.bat calls a utility called Fsize.com
which determines the type of disk being installed from (360K or
other). The other is important because, should the first RunTime
disk be a 1.2 MB disk, then Rinstall expects its files to be arranged
like a 31/2" diskette. If the user wants to distribute 51/4" disks,
then the first disk in the install must be formatted to 360K. If 1.2
MB 51/4" disks are to be distributed, the files must be setup so that
they match a 31/2" configuration. The configuration of files are
shown below.
For 31/2" (or high density 5 1/4"), two disks are needed:
Disk 1:
RTime1.exe
RTime2.exe
RInstall.bat
FSize.com
Disk 2:
RInstall.bat
RTime3.exe
For 51/4" (360K) disks, three disks are needed:
Disk 1:
RTime1.exe
RInstall.bat
FSize.com