Code:
'Demo using a TYPE definition to create a file '*****************TYPE ClientType CName AS STRING * 30 '30 bytes Address AS STRING * 30 '30 bytes City AS STRING * 15 '15 bytes State AS STRING * 2 ' 2 bytes Zip AS STRING * 5 ' 5 bytesEND TYPE ' total size = 82 bytesDIM Client AS ClientTypeRecordLEN = LEN(Client) 'find the size of each TYPE recordOPEN "ADDRESS.DAT" FOR RANDOM AS #1 LEN = RecordLENRESTORE ClientData 'restore to start of DATArecord = 0DO READ CName$, Address$, City$, State$, Zip$ 'read DATA IF CName$ = "END" THEN EXIT DO record = record + 1 'increment record number Client.CName = CName$ Client.Address = Address$ Client.City = City$ Client.State = State$ Client.Zip = Zip$ PUT #1, record, Client 'PUT by record numberLOOPCLOSE #1ENDClientData: DATA "Bob White","104 Birdland Rd.","Bellview","PA","15236" DATA "Ward Cleaver","123 W. Beaver St.","Beaver","PA","15255" DATA "Elmer Fudd","45 Wabbit St.","Bethel Park","PA","15022" DATA "Wyley Coyote","33 Roadrunner Ave.","Clairton","PA","15122" DATA "Jim Morrison","19 Doorway Dr.","Belleview","PA","15236" DATA "END",0,0,0,0,0
Code:
'Demo of the FIELD statement to read the file'*********************************************************************' Define field and record lengths with constants.CONST NM = 30, AD = 30, CT = 15, ST = 2, ZC = 5CONST RLEN = NM + AD + CY + ST + ZC'OPEN "ADDRESS.DAT" FOR RANDOM AS #1 LEN = RLENFIELD #1, NM AS CName$, AD AS Address$, CY AS City$, ST AS State$, ZC AS Zip$FIELD #1, RLEN AS Clist$ 'define entire recordGET #1, 1 'GET does not need a variable to read FIELD records! 'Read file for zip codes from 15230 to 15239 .DO WHILE NOT EOF(1) ZipCheck$ = Zip$ 'read zip codes IF (ZipCheck$ >= "15230" AND ZipCheck$ <= "15239") THEN Info$ = Clist$ PRINT LEFT$(Info$, 30) 'read name string PRINT MID$(Info$, 31, 30) 'read address string PRINT RIGHT$(Info$, 17) 'read city, state and zip code PRINT END IF GET #1 'simply GET reads each FIELD record after firstLOOPCLOSE #1END
Statistics: Posted by burger2227 — Sun Oct 10, 2010 5:09 am
Statistics: Posted by Suraj Joshi — Sun Oct 10, 2010 1:11 am
Statistics: Posted by burger2227 — Thu Oct 07, 2010 12:22 am
Statistics: Posted by burger2227 — Wed Oct 06, 2010 8:30 pm
Statistics: Posted by Suraj Joshi — Wed Oct 06, 2010 7:04 am