reading ra user file

 BBS: Inland Empire Archive
Date: 07-05-92 (13:31)             Number: 188
From: KEN DOEBLER                  Refer#: NONE
  To: JOHN GALLAS                   Recvd: NO  
Subj: reading ra user file           Conf: (2) Quik_Bas
 > As I stated before...  I'm making a program that needs to read in the
 > Remote Access user file, and handle variables (which are numbers), but
 > the ones that I need to handle are stored in a manner which by
 > Pascal is called "Word", which means, unsigned integer, a number ranging
 > from 0 to 65536.  Now how can I take 2 bytes out of this file (the
 > "Word"), and make those 2 bytes into a number, and have it actually give
 > me the right number?  And after you tell me that, how can I take a
 > number, and convert it into 2 bytes?


Here's an example of reading the RA user file and picking
up some of the info stored there:

        OPEN "R", 1, userpath$, 158   'userpath$ = users.bbs
        FIELD #1, 158 AS user$
        nbrusers% = LOF(1) / 158

        FOR recno% = 2 TO nbrusers%   'skip sysop's record
           GET #1, recno%
           x% = ASC(LEFT$(user$, 1))
           IF x% <> 0 THEN             'check for deleted
              tdowns& = tdowns& + CVI(MID$(user$, 139, 2))
              tdownsk& = tdownsk& + CVI(MID$(user$, 143, 2))
              tups& = tups& + CVI(MID$(user$, 137, 2))
              tupsk& = tupsk& + CVI(MID$(user$, 141, 2))
              tmessp& = tmessp& + CVI(MID$(user$, 129, 2))
              tcalls& = tcalls& + CVI(MID$(user$, 135, 2))
              tused& = tused& + CVI(MID$(user$, 147, 2))
              tsecur& = tsecur& + CVI(MID$(user$, 133, 2))
           END IF
        NEXT recno%
        CLOSE #1

Then do whatever you want to do with the results.  This example just
accumulates the total downloads, uploads, calls etc of all
the users, which I later used to make a kind of user
statistics screen from.  I used long integers to accumulate
the totals just to make sure I didn't get an overflow
somewhere along the way in the totals.

To convert the 2 byte string to an integer, just use
CVI(two-byte-string$). Likewise, to convert an integer to a
two byte string, use MKI$(integer), i.e. Two-byte-string$ =

That should get you going... :-)

 * Origin: Technically Stimulating (1:102/330)
Outer Court
Echo Basic Postings

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