dBase iii+ Do While problem
dBase iii+ Do While problem
(OP)
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
RE: dBase iii+ Do While problem
First of all, sorry if this will be of no help in your case. My dBASE knowledge is very limited, most of my memories are about Clipper and FoxPro.
Check whether the valid clause is supported by dBASE's @ .. get :
CODE --> Clipper
Feherke.
feherke.github.io
RE: dBase iii+ Do While problem
Tks for the quick response. Your suggestion didn't work. I got the usual error.
Joe
RE: dBase iii+ Do While problem
I used Dbase many years ago so my knowledge is rusty to say the least.
I'm not sure why you are using the Do while command.
Try using the CASE commands you have structured in its own separate program and run this to see what results you get.
Phil
RE: dBase iii+ Do While problem
Do Case
Case choice = '1'
Replace BWCHECK with 1
Case choice='2'
Replace BWCHECK with 2
Case choice='3'
Replace BWCHECK with 3
Case choice='4'
Replace BWCHECK with 4
Endcase
I am assuming that the field BWCHECK is numeric
Phil
RE: dBase iii+ Do While problem
BWCHECK is a character.
I see that you used the REPLACE command rather than STORE.
I'll give it a try and let you know.
Joe
RE: dBase iii+ Do While problem
Sorry, you do need the Do while bit, I was jumping ahead of myself and of course the replace BWCHECK with a number should be enclosed in quotes; "1" or '1' as it is character.
Phil
RE: dBase iii+ Do While problem
I've just realised that you are not working in a database file and this is why you are getting nil results.
In a do while loop each record is checked by going through the database 1 record at a time from top to bottom
and then a field can be changed if it meets the criteria in a loop or replace/store command.
RE: dBase iii+ Do While problem
I am working in a database. At the top I did say "BWCHECK is a field name of type character with a length of one."
I used your Do Case example. I made the necessary changes and it worked. I also added
@ 2,2 say BWCHECK
so that a "T", a "b", a "B", or an "N" would be displayed on the screen.
What I still do not understand is why original code did not work.
do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 2,2 GET BWCHECK
read
exit
loop
enddo
Joe
RE: dBase iii+ Do While problem
Usually when building a program file you would see the USE command with the dbf filename near the top of the file, so I assume you opened it another way.
In your 'do while' structure I'm not sure why you are using brackets.
Tell me what you are trying to achieve with the Do While loop?
I'm currently working from home because of new lockdown so I will look for my Dbase III command book today to check what commands were valid at the time.
Cheers
Phil
RE: dBase iii+ Do While problem
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.
do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 2,2 GET BWCHECK
read
exit
loop
enddo
As for the parentheses, I recall being taught that way as well as saw it that way in a few example I found online.
I also tried the following to no avail.
do while (BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N")
and
do while (BWCHECK <> "T" .or. BWCHECK <> "b" .or. BWCHECK <>"B" .or. BWCHECK <> "N")
and
do while BWCHECK <> "T" .or. BWCHECK <> "b" .or. BWCHECK <>"B" .or. BWCHECK <> "N"
All I want is for the use to hit one of four letters and go on to the next FIELD/READ or loop back to try again.
Here is a Basic example of how this should work.
10 LOCATE 2,2
20 BWCHECK$=INKEY$
30 IF BWCHECK$="T" OR BWCHECK$="b" OR BWCHECK$="B" OR BWCHECK$="N"
40 GOTO 55
50 ELSE GO TO 10
55 END IF
60 LOCATE 2,2
70 BWSTRIPES$=INKEY$
80 IF BWSTRIPES$="T" OR BWCHECK$="b" OR BWCHECK$="B" OR BWCHECK$="N"
90 GOTO 105
100 ELSE GO TO 60
105 END IF
Joe
RE: dBase iii+ Do While problem
To make sure the correct data is input you would need to have an input screen to validate the letter that the inputter types and will not go any further if the wrong letter is entered.
I don't have Dbase anymore to test any programs on but I do have Visual Foxpro which uses the same language as Dbase and was always 1 step ahead.
Do while 'bBNT' $ bwcheck etc. should work. The $ sign is a substring operator which allows characters to be searched for within another char string.
Let me know what you think.
RE: dBase iii+ Do While problem
The $ sign command works in Foxpro but may not in Dbase.
You could do this;
Set filter to 'bBNT'$BWCHECK
Browse
Dbase should manage to do the above,
you should then be able to see the blanks assuming it is not a massive file.
Which version of dbase do you have?
Phil
RE: dBase iii+ Do While problem
I've sent 2 previous messages, however I've modified your Do while code as follows which works fine:-
close all
clear
USE BWdata
go top
Do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 25,25 GET BWCHECK
read
skip
If eof()
exit
endif
Enddo
clear
return
Would like to know where the CHOICE field fits into this.
I have found my old Dbase manual which covers upto and including Dbase III.
RE: dBase iii+ Do While problem
I am using dBase III+.
I have a DBF called BLACK.DBF. See the attached file.
I have already done the APPEND BLANK command to add a blank record.
One of the fields is called BWCHECK. This field is a character with a length of one.
I want the user to be able to enter one of the following; T, b, B, or N.
The code goes as follows.
clear
use BLACK
set color to
@ 2,2 SAY "█"
@ 3,2 SAY "█"
set color to W+
@ 2,4 say "Black And White Check"
@ 3,4 say "Black And White Stripes"
* More @ SAYs go here.
* After all the @ says are displayed then the @ GET/READs begin.
do while ((BWCHECK <> "T") .or. (BWCHECK <> "b") .or. (BWCHECK <>"B") .or. (BWCHECK <> "N"))
@ 2,2 GET BWCHECK
read
exit
loop
enddo
do while ((BWSTRIPES <> "T") .or. (BWSTRIPES <> "b") .or. (BWSWTRIPES <>"B") .or. (BWSTRIPES <> "N"))
@ 2,2 GET BWSTRIPES
read
exit
loop
enddo
* The remainder @ GET/READs go here.
close all
The problem is that no matter what the user enters, the next GET/READ is done.
I have tried various combinations of parenthesis including none at all.
I hope this makes better sense.
Joe
RE: dBase iii+ Do While problem
I have started to write some code but have noticed the DBF file you sent is empty. It would probably help if some of the data is there for me to use as a test if that's okay.
Phil
RE: dBase iii+ Do While problem
It is blank and is supposed to be blank. I am looking to add a new record to a new (never before used) DBF file and not edit old records. I'll worry about editing after I am able to input new records.
Joe
RE: dBase iii+ Do While problem
Brilliant, that's what I thought. I'll now write an input screen with a type of validation suitable for Dbase III plus.
Phil
RE: dBase iii+ Do While problem
The following works fine.
If okay, it can be refined to suit other fields that need input, maybe with a small menu:-
close all
clear
set confirm on
USE Black.dbf
go top
Do while .t.
X1=' '
@ 3,10 SAY 'Enter value for BWCHECK' get X1
@ 5,10 SAY 'Press esc to exit'
READ
IF READKEY()=12
CLEAR
EXIT
ENDIF
If X1='b'.or.X1='B'.or.X1='N'.or.X1='T'
Append blank
Replace bwcheck with X1
else
@ 8,10 SAY 'Enter one of these values only b B N T '
loop
Endif
Skip
Enddo
Return
Set confirm off
browse
RE: dBase iii+ Do While problem
That worked except that it never would exit. See the attached screen shot.
That's okay. It got me thinking and I resolved the problem.
There is only one record so go top and skip is not needed.
I changed your code as follows. It works perfectly. It allows me to add more fields and exit after the last field.
Tks,
Joe
*go top
Do while .t.
X1=' '
@ 3,10 SAY 'Enter value for BWCHECK' get X1
* @ 4,10 SAY 'Press esc to exit'
READ
* IF READKEY()=12
* CLEAR
* EXIT
* ENDIF
If X1='b'.or.X1='B'.or.X1='N`'.or.X1='T'
* Append blank
Replace bwcheck with X1
exit
else
@ 9,10 SAY 'Enter one of these values only b B N T '
loop
Endif
* Skip
Enddo
*Return
RE: dBase iii+ Do While problem
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
RE: dBase iii+ Do While problem
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
RE: dBase iii+ Do While problem
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
RE: dBase iii+ Do While problem
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
RE: dBase iii+ Do While problem
Thanks for the titles of the books. I remember what mine looked but not the title nor author.
Joe
RE: dBase iii+ Do While problem
@ 2,2 GET BWCHECK valid BWCHECK $ "TbBN"
read
RE: dBase iii+ Do While problem
Valid clause is not in dBase III plus, it appeared in the later version of dBase IV.
RE: dBase iii+ Do While problem
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
RE: dBase iii+ Do While problem
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 ...
...
RE: dBase iii+ Do While problem
“@ 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
RE: dBase iii+ Do While problem
RE: dBase iii+ Do While problem
CODE -->
RE: dBase iii+ Do While problem
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]
RE: dBase iii+ Do While problem
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).
RE: dBase iii+ Do While problem
Is field X1 part of the database?
RE: dBase iii+ Do While problem
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 "@"
RE: dBase iii+ Do While problem
@ 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.
RE: dBase iii+ Do While problem
I don't know Clipper, I used it only to compile programs written in dBase.
For example:
CLIPPER C:\PERSONNEL.PRG
PLINK86 FI PERSONNEL
RE: dBase iii+ Do While problem
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]
RE: dBase iii+ Do While problem
[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.
RE: dBase iii+ Do While problem
I agree with you that all information is beneficial. Perhaps you could create a Forum for Clipper.
Clipper is similar to both dBase and FoxPro so it would be a useful addition.
RE: dBase iii+ Do While problem
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.
RE: dBase iii+ Do While problem
You have repeated what you stated in your previous post.
This is not the forum for continual information on Clipper. This forum is for answers to dBase queries.
Many people/companies are still using old software quite happily. So it would be a positive step to create a forum for Clipper for Clipper users to benefit.
RE: dBase iii+ Do While problem
RE: dBase iii+ Do While problem
That is why Nantucket Corp created Clipper because Ashton-Tate, the creator of Dbase III Plus did not make great commands and functions. They tried to upgrade to Dbase IV but the design and stability were so poor that many users switched to other products like Clipper, FoxBASE+ (later renamed FoxPro), and other so-called Xbase products. Dbase III Plus is only very useful when it comes to Database Management using the dot-prompt (. prompt) interactive command set but not well in programming. That is why even the simple question of joewillerols (Programmer)(OP), Dbase III Plus could not easily do it but Clipper Summer 87 or newer version can.
I'm sorry if my comments may not be favorable to other programmers here. You are all free to continue what you have started. If you really love Dbase III Plus Programming, then just continue. And if you try other programming language, it's more beneficial because you will gain more knowledge and experience.
RE: dBase iii+ Do While problem