No announcement yet.

Trouble with previously working function

  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with previously working function

    Hi All!
    I am trying to revive a chunk of code that was working before I started "streamlining" it. The trouble started when I converted Quickbasic subroutines

    blah, blah

    to PowerBasic subroutines

    More blah
    End SUB

    Now when I try and compile I get an error message "Variable Expected" on one of the fubction declarations. I confirmed that all of the subs had end sub at the end of each. The function was working previously. Does anyone have any ideas where to go next?



  • #2
    From the docs:
    Variable expected - A variable was expected, but not found. A common cause for this error is the use of a reserved keyword as a variable.
    Is it possible you've used a reserved keyword as a variable?


    • #3
      When I port old QB code the most common problem I run into is variable scoping issues. In GOSUB/RETURN blocks all variables maintain their scope during the SubRoutine -- default to global.

      In SUB/END SUB blocks all variables default to LOCAL -- not visible outside the SUB. A variable inside the SUB with the same name as a variable outside the SUB is a different variable.

      And I will repeat John's point with this undeniable truth: PBDOS is a richer programming language than QB so check those reserved words.

      Of course, it you could post the actual code of both versions, I'm sure there is someone here who would be happy to guide you.


      (If you see this MCM: yes, I have been converted. )
      Do not go quiet into that good night,
      ... Rage, rage against the dark.


      • #4
        Originally posted by Steve Andrues View Post
        Now when I try and compile I get an error message "Variable Expected" on one of the fubction declarations.
        I'm pretty sure that if you poste the actual declaration, this forum will sort out the problem in no time, but as my crystal ball is due for maintenance right now, at least I have a hard time to make an educated guess.


        • #5

          When you converted the subroutine, did you put "SUB" in front of the
          name? They want
          SUB subroutine
          ' code
          END SUB
          At least that's what it looks like from what you have posted.