Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dBase iii+ Do While problem

Status
Not open for further replies.

joewillerols

Programmer
Dec 29, 2020
20
US
[pre]BWCHECK is a field name of type character with a length of one.
The only value I want entered is T, b, B, or N.
This is the code I've written. The problem is that BWCHECK will accept any value.
It then exits and goes onto the next field.
Help!

Tks,
Joe

do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 2,2 GET BWCHECK
read
exit
loop
enddo[/pre]
 
Hi,
I'm pleased that the code is now working. However I would like to mention that the code I sent works perfectly at this end including the exit procedure.
The 'go top' command is outside the loop and generally used at the start of programs to ensure the cursor is pointing to the first record in the DBF.
It now leads me to ask why do you only need 1 record ?
Also can you explain the last bit of your comment 'It allows me to add more fields and exit after the last field'.

If you are working with many fields, you may find that a small menu system would help which is easy to put together and would aid inputting.

Would you please send me a copy of the latest DBF file to satisfy my curiosity.

Regards,
Phil


 
Hi Joe,
I forgot to mention in my previous post this morning. I have found another Dbase III plus book which may be a help to you, it is entitled 'DBase III Plus Handbook' which explains the commands and functions used in the software. If it is of interest let me know and I'll post it to you (quite a thick book).

Phil
 
Phil,

It's working fine after the modifications I made. When I BROWse the correct data is where it belongs.

I knew that question would pop up. I only need one record because it is a survey of sorts. Only one person will be filling the questions at any given time. For each new person, I'll give them a blank DBF with only one record.

Do you mean mail me the book as in via the postal service? No need to do that. I suspect that because you said post, you aren't in the USA. If you can attach a pic of the book here. I can look around locally and online to find the book.

Tks,
Joe
 
Hi Joe,
Now you explain about the surveys it at last makes sense.

There are 2 books that are worth buying if you can find them (probably eBay or second hand book shop):-
dBase III Plus A Practical Guide by M. De Pace
dBase III Plus Programmer's Reference Guide by Edward Jones

If you have any more queries please don't hesitate to ask.

Phil


 
Phil,

Thanks for the titles of the books. I remember what mine looked but not the title nor author.

Joe
 
From my lost memory of clipper, this may be working

@ 2,2 GET BWCHECK valid BWCHECK $ "TbBN"
read
 
Hello nsirri,
Valid clause is not in dBase III plus, it appeared in the later version of dBase IV.



 
What version of dBase III Plus are you using?
According to a book of dBase III Plus that I have "do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))" is not valid... The ".or." isn't a opcion for a DO WHILE.



do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 2,2 GET BWCHECK
read
exit ?
loop ?

enddo


 
Analize this code and apply this:



bwcheck = " " && assign a blank value

DO WHILE .T.
@ 2,2 GET dwcheck VALID dwcheck $ "TbBN" && only any letter within quotations are valid
READ
IF dwcheck $ "T"
@ ... your commands here if T is selected/pressed
ELSE IF dwcheck $ "b"
@ ... your commands here if small letter b is selected/pressed
ELSE IF dwcheck $ "B"
@ ... your commands here if capital letter B is selected/pressed
ELSE IF dwcheck $ "N"
@ ... your command here if capital letter N is selected/pressed
ELSE
EXIT && (or RETURN) if any other letter is pressed
END IF
...
...
ENDDO

NOTE: If the commands for b or B are the same, you can use this:

ELSE IF dwcheck $ "Bb"
@ ... your commands here if small letter b or capital letter B is selected/pressed
ELSE ...
...
 
I am analyzing your code, but before I go further, please, explain me
“@ 2,2 GET dwcheck VALID dwcheck $ "TbBN"
&& only any letter within quotations are valid”.
Why not simple
“@ 2,2 GET dwcheck $ "TbBN"
&& only any letter within quotations are valid



 
VALID clause was not available in dBase III plus, it appeared in the later dBase IV.
 
My version:

Code:
CLEAR ALL
CLEAR
SET TALK OFF
USE BLACK
bwcheck = " " && assign a blank value
OPTION = " " && assign a blank value
@ 7,1 SAY 'Only characters "T,b,B,N" will be accepted' 
DO WHILE .NOT.  OPTION $ 'TbBN'
    @5,15 SAY 'BWCHEK: ' GET BWCHECK 
    READ
    DO CASE
        CASE bwcheck = "T"                                 && only any letter within quotations are valid
            APPEND BLANK
            REPLACE X1 WITH UPPER(bwcheck)
        CASE bwcheck = "b"
            WM=' '
            STORE 'b' TO WM 
            APPEND BLANK
            REPLACE X1 WITH WM
        CASE bwcheck = "B"
            APPEND BLANK
            REPLACE X1 WITH UPPER(bwcheck)
        CASE bwcheck = "N"
            APPEND BLANK
            REPLACE X1 WITH UPPER(bwcheck)
    ENDCASE               
    IF BWCHECK='x'                                          && The way to EXIT
        EXIT
    ELSE
        LOOP
    ENDIF
ENDDO

* ------------------------------------------------------to EXCUTE the program: DO ME
* ------------------------------------------------------base: BLACK
* ------------------------------------------------------to  READ the base:  F3
* ------------------------------------------------------to ERASE the base: 1).- DELE ALL    2).- PACK
* ------------------------------------------------------to EXIT the program: 'x'   (LOWER CASE)

 
Hi,
Not sure what you are trying to achieve so I would need to see a copy of your dbf file and then you can tell me what you are trying to do.
I have modified some code at the beginning of the loop and deleted some code at the end of the loop and inserted my own.

DO WHILE .NOT. 'TbBN'$Option

OTHERWISE
EXIT
ENDCASE
ENDDO

If you are inputting to a dbf file the start of the loop would normally read DO WHILE .NOT. EOF()[/b]

 
I anticipate that I am not sure of Joe's demands.
The DO WHILE loop is set to not accept inputs other than "TbBN", to avoid exiting the loop when an invalid key is pressed (modifiable).

The end of the DO CASE is done for convenience in case you want to continue typing or you want to exit (modifiable).

 
If you look back at the previous posts, Joe was happy with the corrected code as of 19th January 2021 and the data files only contained 1 record each.
Is field X1 part of the database?
 
My friends, I'm sorry I forgot to tell you that I am using "Clipper.exe" to compile the .PRG files to .OBJ files and "Plink86.exe" to convert to an executable file.

In Clipper Summer 87 version, VALID is required to validate the input data. That is why only any letter
within the double quotations marks are accepted. Other input not within the quotes will be invalidated.

The following simple tutorial for compiling .PRG files is not intended for the Expert Clipper/Dbase Programmers
but for those who need to know Clipper Summer 87 style of compiling. This may not be 100% related to the discussed
topic but this can help anyone here. My previous post regarding @ GET VALID will be successfully compiled using
Clipper.exe of Clipper Summer 87.

These are the required software/files:
CLIPPER.EXE
CLIPPER.LIB
CURDRV.LIB
EXTEND.LIB
PLINK86.EXE

If you want a very good program/text editor, obtain also "NE.COM" (Norton Editor) for DOS.

You also need to set the PATH of the above files to be successful in compiling.

HOW TO COMPILE AND CONVERT TO EXECUTABLE FILE?

IF ONLY ONE .PRG WILL BE COMPILED AND CONVERTED TO .EXE FILE, (for example, Personnel.prg)

Use this command:

CLIPPER Personnel.prg (then press Enter) - This will create an object "Personnel.OBJ" file
to be used for conversion to .EXE using PLINK86.exe

Then followed by this command:

PLINK86 FI Personnel.prg (then press Enter. This will now create a "Sample.EXE" file

IF MORE THAN 1 .PRG files (ex. Personnel.prg, Payroll.prg, Reports.prg), you have to create
a batch file (ex. PPR.BAT) which will contain the 3 .PRGs

Inside PPR.BAT:
clipper personnel -m -l -q
clipper payroll -m -l -q
clipper reports -m -l -q

After creating PPR.BAT, type this command:

PPR (then press Enter. This will create personnel.obj, payroll.obj, and reports.obj)

NOW, TO CONVERT THE NEWLY CREATED .OBJ FILES TO .EXE FILE, You have to create a .LNK
file (ex. PPR.LNK)

Inside PPR.LNK:
fi
personnel,
payroll,
reports
lib
clipper,extend


After creating PPR.LNK, type this command:

PLINK86 @PPR (then press Enter. This will create "Personnel.exe" file. Don't forget the "@"

 
Answer to: Rosciano (TechnicalUser)

@ 2,2 GET dwcheck - means, at row 2, column 2 allow input for dwcheck variable
VALID dwcheck $ "TbBN" - validates the inputted character to TRUE if found within quotes
&& - this 2 ampersand is for single line comment

Why not simple?
“@ 2,2 GET dwcheck $ "TbBN" - Clipper Summer 87 requires VALID clause

In Clipper Summer 87 version, VALID is required to validate the input data. That is why only any letter
within the double quotation marks are accepted. Other input not within the quotes will be invalidated.
 
AAh... that's why I asked for VALID.
I don't know Clipper, I used it only to compile programs written in dBase.
For example:
CLIPPER C:\PERSONNEL.PRG
PLINK86 FI PERSONNEL

 
Hi,
As I mentioned before the VALID clause was not available in III plus. It is better not to confuse things by relating other programs such as Clipper. Need to concentrate on Dbase III plus as this is the program you are working in.[/b]
 
One major dBase feature not implemented in Clipper is the dot-prompt (. prompt) interactive command set,
[1] which was an important part of the original dBase implementation.

Clipper, from "Nantucket Corp" and later "Computer Associates", started out as a native code compiler for
dBase III databases, and later evolved

Clipper was created as a replacement programming language for Ashton Tate's dBASE III, a very popular
database language at the time. The advantage of Clipper over dBASE was that it could be compiled[6]
and executed under MS-DOS as a standalone application.

So if we know something that is beneficial for those who wants more learning, we should share what
we learned and experienced.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top