Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Here we go again...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Here we go again...

    Just curious: Is there a problem with using A and A% in the first and B%()
    and B% in the second part of my example, respectively? I know, DIM ALL will
    be the best choice, but I'm just porting an old DOS program to 8.04 and it
    would be very easy for me to proceed as I did in my example program below.

    ADDED: my example program works as intended, all results are ok

    Thanks and Regards!
    Hanns

    Code:
    #COMPILE EXE
    DEFSNG A-B  ' <-- cave!!
    FUNCTION PBMAIN () AS LONG
      A=1
      A%=2
      MSGBOX STR$(A)+STR$(A%)
      DIM B%(1:1)
      B%(1)=3
      B%=4
      MSGBOX STR$(B%(1))+STR$(B%)
    END FUNCTION
    Last edited by Hanns Ackermann; 14 Nov 2007, 02:12 PM.

  • #2
    Hanns,

    When I first started using PBWin, someone suggested Dim All and at first I thought it was a big pain, but stuck with it, just to see. The advice was good, it's a good way to head off certain kinds of bugs (typos) at the pass.
    "There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers

    Comment


    • #3
      >and B%() and B%

      This I know does not work: a scalar variable name may not conflict with an array variable name.

      "Work" or "Not Work" aside, coding like this is IMNSHO totally silly. As long as you have to port it, clean it up while you are at it.
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Russ, Michael,

        many thanks for your kind response. Indeed, it was not my intention to get gray hairs
        while coding as I did in my example, it was just to learn somewhat more about the logic
        of the compiler. Nevertheless, following your advice, I'll keep hands off things like this
        and stick to #dim all as I usually used to do.

        BTW, in my example prog the B% and B%() thing works well - AISIMVHO The same is
        with B%(B%), B(B%) and B%(B) etc. - I agree, Michael, may be that's really silly, just
        a question out of curiosity ...

        Regards, Hanns.

        Comment


        • #5
          Maybe 'duplicate' variable names don't work for me because I always use #DIM ALL.

          Regardless, I don't think I've ever even been tempted to use B% (scalar) and B%() (array) in the same procedure.

          Code:
          #SILLY OFF   ' Save me from myself!
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X