Thread: variable names in Waterloo BASIC

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    variable names in Waterloo BASIC

    I have an assignment at work to convert some programs that are on a timeshare server to a more usable format. These programs are around 30 years old and were updated once about 20-25 years ago. They were converted to Waterloo BASIC.

    I'm going over the files right now to get a feel for them until I can get over to the University to order the primer from the system's archive library.

    I see variable names that end in $ and others that do not. For example:
    Code:
    03200 DIM A$(10),B$(10),W(10),H(10),D(10),S(10),F(10),E(10),Q(10),M(10)
    03300 DIM R(10),A(10),P(10),K(10),Y(10),FT(2),PT(2),MT(2),YT(2),V(10)
    You'll notice there is a A$ and an A variable.

    Anyone know what the difference is and what the $ means?

    I'm not that familiar with basic and I haven't seen $ used like that in the VBA I've written.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    In many Basic dialects, the symbolic postfix is a type annotation. In other Basic dialects, there are other ways to do this. The $ postfix is for strings.
    E.g. in VB, this:
    Dim A as String
    and this:
    Dim A$
    are equivalent, except that the second variable is called "A$". They're both of type String, whereas suffix-less variables are of no type - they're variants. Although I'm not sure about that in other dialects, so for all I know, in Waterloo suffix-less variables could be integers.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Ok thanks a bunch.

    Reading through the code I had noticed that all of the $ postfixed variables were being used as strings but I wasn't sure if that was a syntax thing or a convention thing.

  4. #4
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    If its the same as Blitz Basic then a hash (#) postfix means the variables a float.By default all values are integers; a % postfix can be used to explicitly declare this but is not necessary. You only need to use a postfix when you first declare a new variable, but I find its good to use them all the time to make code clearer.
    Last edited by mike_g; 12-27-2007 at 02:33 PM.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Do either of you know what the difference between ! and REM is? From the code it looks like both are comments and ! can be used as an equivalent to //.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. variable setting (very basic very strange)
    By kind2allpeople in forum C++ Programming
    Replies: 3
    Last Post: 02-03-2006, 04:32 PM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  3. why is i the standard counting variable?
    By ssjnamek in forum C++ Programming
    Replies: 18
    Last Post: 09-21-2005, 06:53 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Use of variable
    By alice in forum C Programming
    Replies: 8
    Last Post: 06-05-2004, 07:32 AM