• Mystic structures

    From Manuel Adorni@4:902/27 to All on Wed Mar 23 12:35:53 2022
    ­Hola All!

    Anyone have an Mystic BBS structures for QBasic?

    Thanks.

    ­Saludos!
    -=Momia=-

    --- GoldED+/W32-MSVC 1.1.5-b20170303
    * Origin: Momia BBS (4:902/27)
  • From Nick Andre@1:229/426 to Manuel Adorni on Wed Mar 23 17:31:55 2022
    On 23 Mar 22 12:35:53, Manuel Adorni said the following to All:

    Anyone have an Mystic BBS structures for QBasic?

    Likely not, but its easy to do Pascal to Basic. Use my two function calls:

    DECLARE FUNCTION Bas$ (text$)
    DECLARE FUNCTION Pas$ (text$)
    FUNCTION Bas$ (text$)
    IF LEN(text$) > 0 THEN
    Bas$ = MID$(text$, 2, ASC(MID$(text$, 1, 1)))
    END IF
    END FUNCTION
    FUNCTION Pas$ (text$)
    IF text$ <> "" THEN
    Pas$ = CHR$(LEN(text$)) + text$
    ELSE
    Pas$ = ""
    END IF
    END FUNCTION

    You use these Qbasic functions when you work to-and-from Pascal strings because the first byte is the length of the string.

    So if you had this Pascal structure:

    type my_structure = record
    something as string[255];
    end type;
    var my_data = my_structure;

    In Qbasic it would be:

    TYPE MYSTRUCTURE
    SOMETHING AS STRING * 256
    END TYPE
    DIM MYDATA AS MYSTRUCTURE

    Then in Qbasic you would use this to retrive the value:

    BasicText$ = Bas$(MYDATA.SOMETHING)

    For storing a Basic string to Pascal, it would be:

    MYDATA.SOMETHING = Pas$(BasicText$)

    Booleans and Char Pascal-types are one byte, so STRING * 1 in Basic. A boolean True equals CHR$(1).

    When working with records, you must define the length of the structure in the Qbasic OPEN call:

    THEPOSITION = 1
    OPEN "MYSTIC\COWBELL.DAT" FOR RANDOM AS #1 LEN = LEN(MYDATA)
    GET #1, THEPOSITION, MYDATA
    CLOSE #1

    Hope this helps,

    Nick

    --- Renegade vY2Ka2
    * Origin: Joey, do you like movies about gladiators? (1:229/426)