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 gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dbase 4

Status
Not open for further replies.

andy2004

Programmer
Jan 16, 2004
1
GB
i am a beginner when it comes to programming etc, so i was wondering whether you could help me,

I ahve a database which at the minute only accepts 6 digit job numbers, i need to make this be able to use 7 digit job numbers or possibly alpha numeric.

If this is possible could you please tell me how to change this.

Thanks
Andy
 
Well, becareful with this, because you could ruin your data, so back up your tables before doing these things.

Dbase 4 has a dot prompt I think. At the dot, type
Use "Put your table name here" exclusive
modi stru

After you enter modi stru, you should see the table structure, and be able to make changes to it.

Other tables that use the same field will have the same changes required.

Remember to reindex afterwords.

ChaZ

Ascii dumb question, get a dumb Ansi
 
If you use custom entry screens you may also have to adjust them. For example, if it used the PICTURE statement then this code would be outdated with the larger field:

@ 5,5 SAY "Enter Invoice # " GET nInvNo PICTURE "999999"

It would also need to be enlarged:

@ 5,5 SAY "Enter Invoice # " GET nInvNo PICTURE "9999999"

Also, if you have any other data, including table index expressions, which incorporated or manipulated that 6 digit data then you'd have to examine it too or you may end up with "******" rather than a number:

cDesc = RIGHT("000000"+STR(nInv,6))+" "+cOrderType

It all depends on how the rest of your code is written.
 
That last sample should have been:

old:
Code:
cDesc = RIGHT("000000"+STR(nInvNo,6),6)+" "+cOrderType
new:
Code:
cDesc = RIGHT("000000"+STR(nInvNo,7),7)+" "+cOrderType

That's assuming, of course, you are using numeric not character data.

Strangely enough, dBase does not have an easy way to programmatically determine what the maximum size of a table field is. Something like this might help determine the maximum:
Code:
* this example assumes whole numbers (integers)
* since if you have a field such as "9999.99" it
* will strangely enough allow you to put "9999999"
* in it and bump the decimal point to the right.
USE test
nSave = test.nInvNo
nMaxSize=0
FOR x = 1 TO 15
   y = REPLICATE("1",x)
   REPLACE nInvNo WITH VAL(y)
   IF y = STR(test.nInvNo,x)
      nMaxSize = x
   ELSE
      EXIT
   ENDIF
NEXT
REPLACE nInvNo WITH nSave  && restore original field contents
? "Maximum digits possible: "+LTRIM(STR(nMaxSize))
dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top