Shop OBEX P1 Docs P2 Docs Learn Events
Using an objects constants — Parallax Forums

Using an objects constants

Steve Hicks (N5AC)Steve Hicks (N5AC) Posts: 20
edited 2006-11-05 19:50 in Propeller 1
I have an object that has some parameters that are "mode switches."· The value being passed in determines how the function will handle the other data.· I would like to define these as constants in a CON section such as

CON
· rateSlow = 4800
· rateFast = 9600

.....

OBJ
· myObject: "myObject"

PUB Start
· myObject.Init (rateSlow)

My problem is that I seem to have to define these (constants) in both the object used as well as the program using the object.· Is this correct?· Is there an elegant way to do this other than extracting the constant section out of the object in use and pasting it in the consumer of the object?

Thanks,
Steve

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Steve, N5AC

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-11-05 19:45
    Steve,

    You can use the notation Object#rateSlow to do just what you're after. (See page 141 of the manual.)

    -Phil
  • Steve Hicks (N5AC)Steve Hicks (N5AC) Posts: 20
    edited 2006-11-05 19:50
    Thanks, Phil!· Just what I was looking for.· I always read the manual for a new part cover to cover which I did this time, but I must have forgotten by the time I got to the end!

    Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Steve, N5AC
Sign In or Register to comment.