BBS: Inland Empire Archive Date: 04-19-92 (17:18) Number: 108 From: MICHAEL MALLEY Refer#: NONE To: TOM HAMMOND Recvd: NO Subj: Fixed-length array help Conf: (2) Quik_Bas
TH> OPEN a file for BINARY and determine the number of fixed-length TH> records it contains. TH> Create an array in memory to hold the contents of the file OPENed TH> above. You don't need to use BINARY try this: TYPE WhateverType Whatever AS INTEGER END TYPE '$DYNAMIC DIM Array(1 TO 1) AS WhateverType OPEN "TEST.DAT" FOR RANDOM AS #1 LEN = LEN(Array(1)) REDIM Array(1 TO LOF(1) \ LEN(Array(1))) Using LEN(Array) in all of these places does two things. First it insures that the proper length is always there without you having to sit down and count bytes. Secondly, you can make a change to the TYPE variable and the program will run correctly without having to track down all of the length values. TH> Read the input file and load the data into the array. FOR Counter% = 1 TO UBOUND(Array) GET #1, , Array(Counter%) NEXT Counter% Hope this helps Tom. - Michael * SLMR 2.1a * My compiler has a first name, it's Q.U.I.C.K. --- Maximus 2.01wb * Origin: UltraTech - Nashville, TN (615) 356-0453 {HST} (1:116/30)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET