You were close. Drop the 'name argument and use the following syntax to
create your object:

Logo1: logo-factory

I suppose you COULD keep the 'name argument, then use 'set within the
function to give this a value, but I use the example above to create my
objects. There are a couple more details to the argument approach; if you
really want to do things this way just ask and I'll spell it out.

- Michael Jelinek





[EMAIL PROTECTED] on 08/17/2000 10:36:41 AM

From: [EMAIL PROTECTED] on 08/17/2000 10:36 AM

Please respond to [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
cc:
Subject:  [REBOL] returning an object from a function, sort of


hiall

btw, I sent a message almost identical to this one from my home account
last
night, and it isn't here. Is it because the list doesn't rec that other
account?

anyway...

I've got a function called logo-factory that accepts a string argument, and
should return an object referenced by a word = the passed string. ie., if I
type

           *logo-factory Logo1*

I should get the same result as if I typed

           *Logo1: make object! [....]*

I'm befuddled as to how to do this exactly -- I'm sure the answer is right
under
my nose ;-)

Here's sort of what I have so far:

*
logo-factory: func [
    "Creates and returns a named logo object."
    name [string!] "The name of the object to be created."
][
    ????? 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"]
        ]
    ]
]
*

Obviously, there's a lot missing here, like handling an argument string
which
can't be used as a valid word, etc. Other functions like get-pict and
write-html, etc., also need to be added.

Any and all suggestions are welcome!


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









Reply via email to