Coder Social home page Coder Social logo

Comments (3)

FellippeHeitor avatar FellippeHeitor commented on May 22, 2024

Labels are scope-dependant in QuickBASIC. The code above will yield a "Label not defined" error in Function Foo(x). If you had another Yikes label in FUNCTION Foo(x) that would be valid too - no duplicate if different scope.

Only case of cross-procedure GOTO is with ON ERROR GOTO, which always requires a label in the main module (unless you consider ON LOCAL ERROR GOTO, which is about another type of BASIC, not historical ones).

from wwwbasic.

flagxor avatar flagxor commented on May 22, 2024

Thanks Fellippe.
Labels per function sounds sane.

Do you know offhand how names work in terms of different types of objects?
Are variables, subroutines, functions, and labels all in one namespace, or is there some separation?
(Things easily answered for one version, but figure QB64 folks have a better sense of over multiple versions etc.?)

from wwwbasic.

FellippeHeitor avatar FellippeHeitor commented on May 22, 2024

I couldn't answer about multiple versions. We QB64 folks are all about QBasic/QuickBASIC 4.5 only.

The answer here is: same namespace.

The exception is for SHARED variables. You can have a variable DIM SHARED in the main module, which makes it accessible in sub/functions, but then you can override it and have a local variable of the same name/type that is local to a procedure.

DIM SHARED a AS LONG
a = 1
mySub

SUB mySub
    DIM a AS LONG
    PRINT a
END SUB

That prints 0, not 1, as a is now local to mySub.

from wwwbasic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.