[EMAIL PROTECTED] wrote:
> 
> Hi Pete,
> 
> To be able to pass a word to your function and have the word set to the
> object created in the function requires two changes to your code:

I could also do it like:

logo-factory: func [
[        "Creates and returns a named logo object."
[        'name [word!] "The name of the object to be created."
[      ][
[        set name make object! [
[            type: "text"
[            text: ""
[            pict: #{}
[            file: ""
[            altt: ""
[            switch-type: func [
[                     "Toggles the logo object's type between 'text' and
'pict'."
[                  ][
[                     type: either type = "text" ["pict"]["text"]
[                ]
[          ]
[    ]

example use:

>> logo-factory Logo1
>> logo-factory Logo2
>> probe Logo1

make object! [
    type: "text"
    text: ""
    pict: #{}
    file: ""
    altt: ""
    switch-type: func [
    {Toggles the logo object's type between 'text' and 'pict'.}
][
    type: either type = "text" ["pict"] ["text"]
]
]
>> Logo1/text: "Emporium of Liquid Fun"
== "Emporium of Liquid Fun"
>> Logo1/switch-type
== "pict"
>> probe Logo1

make object! [
type: "pict"
text: "Emporium of Liquid Fun"
pict: #{}
file: ""
altt: ""
switch-type: func [
    {Toggles the logo object's type between 'text' and 'pict'.}
][
    type: either type = "text" ["pict"] ["text"]
]
]
>> probe Logo2

make object! [
type: "text"
text: ""
pict: #{}
file: ""
altt: ""
switch-type: func [
    {Toggles the logo object's type between 'text' and 'pict'.}
][
    type: either type = "text" ["pict"] ["text"]
]
]

But, of course, after all that, I see now that it might be better if the object
were internally identified, rather than depending upon the word that happens to
reference it ;-)

make object! [
        name: "Logo1"
        type: "Primary Store Logo"
        styl: "text"
        text: "Emporium of Liquid Fun"
etc...

-- 
Pete Wason|"LWATPLOTG"|[EMAIL PROTECTED]|[EMAIL PROTECTED]|CUCUG|TA|PHX

Reply via email to