RA USER 1/2

 BBS: Inland Empire Archive
Date: 01-15-93 (16:24)             Number: 388
From: JOHN GALLAS                  Refer#: NONE
  To: MARK THOMAS                   Recvd: NO  
Subj: RA USER               1/2      Conf: (2) Quik_Bas
MT>  I was wondering if anyone out there knows how to access
MT>the Remote Access User base. I have looked at RASTRUCT.100,
MT>but derned if I know what I'm looking at. I have a full
MT>understanding of sequential files, so Iguess what I'm asking

Do you have any understanding of random access files?  Thats what it
is..  I have the structure and code, in QB, see below.

MT>is how does the structure relate to QBable files commands.
MT>  I would post the structure, but I'm not sure how legal
MT>it would be, as it has a copyright with it.

Nope its not illegal.

'* * * * * * * * * * * * * * * * * * * * *
'* RDRAUSER.BAS -                        *
'* Program to read the RA 1.11 user file *
'* * * * * * * * * * * * * * * * * * * * *

DEFINT A-Z

' RA uses a method of storing numbers called "Word", which is an unsigned
' integer, so instead of being a 2 byte number from -32768 to +32767, it
' is a 2 byte number from 0 to 65536, which can come in very handy for
' saving space when storing large numbers.  The StrToVal! function will
' take the two byte number, and convert it into a number from 0 to 65536,
' and the ValToStr$ function will take a number (0-65536) and change it
' into 2 bytes, so you can store the number in the file.

DECLARE FUNCTION StrToVal! (WordBytes$)
DECLARE FUNCTION ValToStr$ (WordValue!)

' When storing strings, RA will add an extra byte at the beginning of each
' string, which will tell how much of the actual string is part of the
' actual string.  For instance, the following string:
' Harold Mishmashijdo239cndlape94jsnc would actually mean "Harold Mishmashi".

' And so, the formula for decoding an RA string is:
' NewString$ = MID$(OldString$, 2, ASC(CHR$(LEFT$(OldString$,1))))
' And thats what UVal$ does, so you don't have to type ^^^^^^.

DECLARE FUNCTION UVal$ (Sumpin$)

' The type for the RA user file.  Each of the entries that have a 'W after
' them are the unsigned integers, and must be manipulated by the StrToVal!
' and ValToStr$ functions.

TYPE RAUserFileType
  UName          AS STRING * 36
  Location       AS STRING * 26
  Password       AS STRING * 16
  DataPhone      AS STRING * 13
  VoicePhone     AS STRING * 13
  LastTime       AS STRING * 6
  LastDate       AS STRING * 9
  Attribute      AS STRING * 1

  ' now here comes the confusing part.  if bit 1 is set in flaga, that
  ' means that the first flag in a is set, etc..  I'm too tired to explain
  ' any further.  If ya don't understand, post what I just said on the
  ' Quik_bas echo and somebody will explain it to ya.

  flaga          AS STRING * 1
  flagb          AS STRING * 1
  flagc          AS STRING * 1
  flagd          AS STRING * 1
  Credit         AS STRING * 2 'W
  Pending        AS STRING * 2 'W
  MsgsPosted     AS STRING * 2 'W
  LastRead       AS STRING * 2 'W
  Security       AS STRING * 2 'W
  NoCalls        AS STRING * 2 'W
  Uploads        AS STRING * 2 'W
  Downloads      AS STRING * 2 'W
  UploadsK       AS STRING * 2 'W
  DownloadsK     AS STRING * 2 'W
  TodayK         AS INTEGER
  Elapsed        AS INTEGER
  ScreenLength   AS STRING * 2 'W
  LastPwdChange  AS STRING * 1
  Attribute2     AS STRING * 1
  Group          AS STRING * 1
  XIrecord       AS STRING * 2 'W
  ExtraSpace     AS STRING * 3
END TYPE

DIM User AS RAUserFileType

' And this little routine'll read in all the users, print their names, their
' locations, and how many messages each user has posted, and then it'll print
' the total messages that have ever been posted by the current users.

COLOR 15, 0
LOCATE , , 1, 12, 13
CLS

PRINT "Reading in users..."
PRINT "Found user: "
PRINT "From      : "
PRINT "Posted    : ";

OPEN "\RA\USERS.BBS" FOR RANDOM AS #1 LEN = LEN(User)  'or whatever the
                                                       'pathname is.

TotalUsers! = LOF(1) \ LEN(User)  'make it a long integer cause theres
                                  'no limit on how many users there can
                                  'be.

FOR i = 1 TO TotalUsers!
   GET #1, i, User
   LOCATE 2, 13
   PRINT UVal$(User.UName) + SPACE$(36);
   LOCATE 3, 13
   PRINT UVal$(User.Location) + SPACE$(36);
   LOCATE 4, 13
   PRINT StrToVal!(User.MsgsPosted)
   TotalPosts! = TotalPosts! + StrToVal!(User.MsgsPosted)
   a$ = INKEY$
   IF LEN(a$) THEN
      a$ = LCASE$(a$)
      IF a$ = "p" THEN
            x$ = INPUT$(1)
      END IF
      IF a$ = "q" THEN
            CLOSE #1
            END
      END IF
   END IF
NEXT i

CLOSE #1

PRINT
PRINT TotalUsers!; "users, and"; TotalPosts!; "posts."
END

FUNCTION StrToVal! (WordBytes$)

Vl! = ASC(RIGHT$(WordBytes$, 1))

Vl! = (Vl! * 256)

Vl! = Vl! + ASC(LEFT$(WordBytes$, 1))
>>> Continued to next message

 * OLX 2.1 TD * BASIC programmers don't die, they GOSUB without RETURN

--- TMail v1.30.4
 * Origin: TC-AMS MLTBBS 2.2 - Minnetonka, MN (612)-938-4799 (1:282/7)
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