>>&& WRITTEN BY MOHAMMAD ZAHEER EMAIL: ZAHEER_M@HOTMAIL.COM >> >>&& BEFORE RUNNING THIS PROGRAM YOU SHOULD CERATE POS.TXT FILE CONTAINING >>&& FIXED LENGTH RECORDS OF WIDTH 48 >>close all && comment >>IF FILE('POS.DBF') && CHECKING BEFORE UPDATING POS.DBF BECAUSE >> ERASE POS.DBF && THE LAST CHANGES HAVE BEEN DONE SO THIS TIME >>ENDIF && POS.DBF SHOULD BE CREATED NEW FROM POS.TXT >> && THE FOLLOWING COMMAND WILL CREATE POS.DBF STRUCTURE WE NEED THE SAME >> && STRUCTURE EACH TIME SO BY THIS PROGRAM ALL THE STRUCTURE INFORMATION >> && IS SAVED. >>create table pos.dbf(posfield c(48),pbcode c(12),; >> pdep n(4), piprice n(14,2),pdesc c(18)) >> && THE FOLLOWING COMMAND WILL APPEND ONLY ONE FIELD FROM POS.TXT >> && POS.TXT HAS FIXED LENGTH RECORDS. THIS APPENDED FIELD CONTAINS >> && ALL THE FIELDS >>append from c:\itemver\pos.txt delimited && THE PATH IS MENTIONED FOR POS.TXT >>go top && GO TO BEGGING OF FILE >>do while .not. eof() && Now replacement of other field from first field will >> && carry on until end of file, because the first >> && filed is containing all data for all fields >> >> replace pbcode with posfield >> replace pdep with Val(substr (posfield,13,4)) >> replace piprice with Val(substr(posfield,17,12)); >> +(Val(substr(posfield,29,2))/100) && to convert text to numeric >> replace pdesc with substr(posfield,31,48) >> skip >> loop >>enddo >>&& NOW REPLACEMENT IS COMPLETE AND WE WILL DROP THE FIELD POSFIELD WHICH >>&& WE HAVE MADE FOR TEMPORARY DATA STORAGE. WE ALSO CHANGE THE DATA FIELD >>&& TYPE >>alter table pos.dbf drop column posfield alter column pbcode n(12) >>return >>&& NOW YOUR TABLE IS READY TO USE IN FORM ETC. >>&& YOU CAN USE THE SAME WAY FOR OTHER TEXT FILE CONVERSION TO TABLE. >>&& I HAVE USED THE SAME PROGRAM TO CONVERT THE ANOTHER TEXT FILE TO DBF FILE >> >> >>********************THE DOWN IS JUST ANOTHER SAME CONVERSION OF IVAS400.TXT >> >>&& comment >>IF FILE('IVAS400.DBF') && CHECKING BEFORE UPDATING IVAS400.DBF BECAUSE >> ERASE IVAS400.DBF && THE LAST CHANGES HAVE BEEN DONE SO THIS TIME >>ENDIF && IVAS400.DBF SHOULD BE CREATED NEW FROM IVAS400.TXT >>creat table ivas400.dbf(ivas400 c(155),asidep c(2),; >> asino c(6),asidesc c(40),asibrand c(10),asiwhp c(4),; >> asimp c(4),asisp c(4),asiboxco c(12),asiboxp n(10,2),; >> asipcsco c(12),asipcsp n(10,2),asiwhqty n(10,0),; >> ast1qty n(10),ast2qty n(10),ast5qty n(10),expdt c (8)) >> >>append from c:\itemver\ivas400.txt delimited && APPEND FROM IVAS400.TXT >>go top >>do while .not. eof() >>replace asidep with ivas400 >>replace asino with substr (ivas400,3,8) >>replace asidesc with substr(ivas400,9,48) >>replace asibrand with substr(ivas400,49,58) >>replace asiwhp with substr(ivas400,59,62) >>replace asimp with substr (ivas400,63,66) >>replace asisp with substr(ivas400,67,70) >>replace asiboxco with substr(ivas400,71,82) >>replace asiboxp with val(substr(ivas400,83,8)); >> +(val(substr(ivas400,91,2))/100) && to convert text to numeric >>replace asipcsco with substr (ivas400,93,104) >>replace asipcsp with val(substr(ivas400,105,8)); >> +(val(substr(ivas400,113,2))/100) >>replace asiwhqty with val(substr(ivas400,115,10)) >>replace ast1qty with val(substr(ivas400,125,10)) >>replace ast2qty with val(substr(ivas400,135,10)) >>replace ast5qty with val(substr(ivas400,145,10)) >>replace expdt with substr(ivas400,155,10) >>skip >>loop >>enddo >>alter table ivas400.dbf drop column ivas400; >> alter column asiboxco n(12) alter column asipcsco n(12); >> alter column asidep n(2) >>return >>&& end of replacement of text files to data base files >