Liberty Basic

Bonjour,
I would like to learn programming, I bought the book "Learning to Program for Dummies" and it explains how to program with Liberty Basic. At one point, I come across a program that I don’t understand. The topic of this program is "Extracting Characters from a String", I understand the purpose of the given example...

Ex:
FullName$ = "John Barkley Doe"
FirstName$ = LEFT$(FullName$, 4)
PRINT "First Name: "; FirstName$
LastName$ = RIGHT$(FullName$, 3)
PRINT "Last Name: "; LastName$
SecondName$ = MID$(FullName$, 6, 7)
PRINT "Second Name: "; SecondName$
END

... what I don’t understand are the numbers in the parentheses regarding the variables!!!! I really don’t see what the 3, 4, 6, and 7 are for, but they must be important because when we remove them, it doesn’t work anymore...
So if someone can help me, thank you in advance.

6 answers


  1. FullName$ = "John Barkley Doe"
    FirstName$ = LEFT$( FullName$, 4)
    PRINT "First Name: "; FirstName$
    LastName$ = RIGHT$( FullName$, 3)
    PRINT "Last Name: "; LastName$
    SecondName$ = MID$(FullName$, 6, 7)
    PRINT "Second Name: "; SecondName$
    END

    Hello Iron,

    I don't know if anyone has already replied, but I'm doing it anyway

    So the strings associated with FullName$ are very important
    indeed for first name left$ meaning left of the full name and the 4 means the first 4 letters of the full name
    that is "John"

    Likewise for lastName$ 3 characters from the right right$ meaning "Doe"

    concerning the second name, the 6 corresponds to starting from the J of "John" we count 4 characters of "John" + space = 5 characters, so the "B" of "Barkley" starts at the 6th position and counts 7 characters hence (6,7)

    There you go, I hope you understood, I salute you
    0
    1. Looking for the answer to a question before asking it is
      half of the work done. Knowing how to formulate it is an art.
      0
      1. Well thank you, I appreciate you enlightening me on this point. I can therefore continue my learning. Thanks again, see you next time.
        0
        1. I don't know, but apparently:
          the syntax of LEFT(string, x)
          should mean that it returns the first x characters
          (so from position 1 to x)
          the syntax of RIGHT(string, y)
          should mean that it returns the last y characters
          (so from position length(string) to length(string)-y)

          and MID(string, x, y)
          returns y characters starting from position x
          (so from position x to x+y)

          Searching for the answer to a question before asking it is
          half the work done. Knowing how to formulate it is an art.
          0
          1. FullName$ = "John Barkley Doe" FirstName$ = LEFT$( FullName$, 4) PRINT "First Name : "; FirstName$ LastName$ = RIGHT$( FullName$, 3) PRINT "Last Name : "; LastName$ SecondName$ = MID$(FullName$, 6, 7) PRINT "Second Name : "; SecondName$ END 


            Hello!
            The first variable is fullName$
            Then, firstName$ is equal to left$(fullName$, 4), which means, left(of the variable, 4), that is, the 4 leftmost characters of your variable...
            PRINT "first name:" firstName$ will display: first name: John
            Then the RIGHT$ function takes as arguments your variable and after the comma the number of characters it takes, from the right, here: Doe.
            Finally, the MID$ function includes 3 arguments: the variable, the start of what you want to extract, and the number of characters you want to extract).

            Like: "we are on ccm" is the variable var$
            left$(var$, 6)= we ar
            right$(var$, 5)= r ccm
            mid$(var$, 3, 6)=e are o

            That's it!

            @+
            0