Shop OBEX P1 Docs P2 Docs Learn Events
Scope of Variables in PropBasic — Parallax Forums

Scope of Variables in PropBasic

FriedVFriedV Posts: 77
edited 2011-08-28 05:06 in Propeller 1
Hi,
is it right that Cog Vars are always global, whether defined in SUB or in the main program?
Is this true for Tasks also?
So if a want to use the same subroutine in the main program and in a task do i need to give them different names, and different names for the variables also?
Thx, Fried

Comments

  • BeanBean Posts: 8,129
    edited 2011-08-28 05:06
    HUB variables and DATA are global to all tasks.

    VARs and SUBs are global to the task. Other tasks can use the same name.
    If a different task needs the same SUB, you need to have it twice. This is a waste for LMM, but it's tricky to try to share SUBs.

    Bean
Sign In or Register to comment.