From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Irv Kalb
Sent: Sunday, 31 December 2000 16:55
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l>appending a propList to another list


At 5:57 AM +0400 12/31/00, gopinath wrote:
>Hi Kerry and Ramesh,
>
>this is my script after all the help
>
>>property therecord, thedatabase
>>  on new me
>>  thedatabase=[:]
>>  global RecordNUM
>>  RecordNUM=RecordNUM+1
>>  set recnum=RecordNUM
>>  therecord=[#RecordNUM:recnum,#theword:" ",#themeaning:" "]
>>  thedatabase.append(therecord))
>>  put thedatabase
>>  return thedatabase
>>  end
>it just doesn't work
>the error is:
>'handler not found in object'
>This is NO project
>I am just learning
>so no hurry
>I am using D7
>regards
>Gopinath
>

Gopinath,

It looks like you are trying to build a database inside an object. 
If this is what you are trying to do, then I would make a few 
modifications.  For example, split out the adding a record from the 
"new" handler. Something like this (untested):

-- Database parent script
property thedatabase
on new me
    thedatabase = []  -- this is a simple linear list
    return me
end

on addrecord me, theword, themeaning
    therecord = [#theword: theword, #themeaning: themeaning]
    thedatabase.append(therecord)  -- each record is itself a property list
end

First you create your database object like this:

global gDatabaseObject
gDatabaseObject = new(script "DataBase")

Then when you want to add records to your database, you would do:

global gDatabaseObject
gDatabaseobject.addrecord("eat", "to consume food")
gDatabaseobject.addrecord("type", "to press keys on a keyboard")

Later, you could add more handlers to your object, for example:

on findMeaning me, theWordToFind
   nItems = count(thedatabase)
   repeat with i = 1 to nItems
     thisRecord = thedatabase[i]
     if thisRecord.theword = theWordToFind then
        return thisRecord.themeaning
     end if
   end repeat
   alert("Could not find" && theWordToFind && "in the database")
end

And call it like this:

theMeaning = gDatabaseobject.findMeaning("eat")

Good luck.

Irv


-- 
Lingo / Director / Shockwave development for all occasions.

        (Over two millions lines of Lingo code served!)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to