Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] returning an object from a function, sort of Re:

From: jelinem1:nationwide at: 17-Aug-2000 11:07

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 [zoon--stumpworld--com] on 08/17/2000 10:36:41 AM From: [zoon--stumpworld--com] on 08/17/2000 10:36 AM Please respond to [list--rebol--com] To: [list--rebol--com] 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"|[zoon--stumpworld--c]|[mrzoon--hynoom--c]|CUCUG|TA|PHX