> Totally my project got 100 pages. I divided the pages into four movies (25
> pages for each movie). I am displaying all the text files in text member only
> not as field member.
> 
> My reguirement is,
> 
> If the user clicks the search button one MIAW should come there he can type
> any word to search.

> When it displays the result it should go to the particular page, it may be in
> any one of the movie.
> 
> How can I trap the movie file name and the frame number.

Hi,

You basically need a database which matches the text to be search to a frame
and movie. You can use an Xtra, such as the excellent v12 (from
http://www.integration.qc.ca/), or you might be able to do it with lingo
(the cheapest way).

Database Xtra Approach 1:
A common way is to run the whole project in one frame (whereby you set the
text of a single member to the text you get from a database). Usually this
is the easiest thing to do, but sometimes the next approach is better.

Database Xtra Approach 2:
This approach is good when the layout of each text is unique and needs to be
done carefully by hand. In this approach, you leave the text that gets shown
laid out in director and just use the database as a search engine. At the
last moment, you import all the text from the relevant castmembers into the
database, and also record the movie and frame number that the text member is
displayed in. You import the text so you can search it, and when you get a
match, you get all the information Director needs to show the right frame
from the database.

Lingo only Approach:
This approach is fine for smallish databases, but can be slow and RAM
intensive. 

Basically, you would create a record for the 'database' like this

  record = [:]
  record[#text] = "The text which will be searched"
  record[#title] = "The title to show on the search results"
  record[#movie] = the movie its in
  record[#frame] = the frame its in
  etc

and then the record would be added to the big 'database' list
  gDatabaseList.append(record)

(this approach assumes that each text member only ever appears once. If text
members appear or more locations than one, it would be more efficient to
create a 'one-to-many' style database)


Hopefully you should be able to automate creating this list. For example, if
sprite 4 displays the text that you want to search, and sprite 5 displays
the title for the page, then you could build the list like this for each
movie 

on createDatabase 
  global gDatabaseList
  if voidP(gDatabaseList) then gDatabaseList = []
  repeat with frameNum = 1 to 25
    go to frame frameNum
    record = [:]
    record[#text] = sprite(4).member.text
    record[#title] = sprite(5).member.text
    record[#movie] = the movieName
    record[#frame] = the frame
    gDatabaseList.append(record)
  end repeat
end

Now you need some way to store this list. The easiest way would be to create
a castlibrary which all the movies can access. Assuming this castlib was
called "SearchDatabase", you could create a field cast member and store each
record in it. For example

on saveDatabase
  global gDatabaseList
  mx = gDatabaseList.count
  repeat with j = 1 to mx
    record = gDatabaseList[j]
    if member(j, "SearchDatabase").type = #empty then
      newMember = new(#field, member j of castLib "SearchDatabase")
      newMember.text = string(record)
    else -- assume there are only fields in this cast
      member(j, "SearchDatabase").text = string(record)
    end if
  end repeat
end

And then to read the database back into a list (which is much faster to
sort)

on openDatabase
  global gDatabaseList
  gDatabaseList = []
  mx = the number of members of castlib "SearchDatabase"
  repeat with j = 1 to mx
    recordStr = member(j, "SearchDatabase").text
    gDatabaseList.append(value(recordStr))
  end repeat
end

Then to search the database, you could do stuff like this:

on searchDatabase pSearchString
   global gDatabaseList, gCurrentResultSet
  if voidP(gDatabaseList) then openDatabase() -- make sure its been opened
   gCurrentResultSet = getRecordsContaining(pSearchString)
   numHits = gCurrentResultSet.count
   if numHits = 0 then
     alert "Sorry, no matches found"
   else
    alert "Found " & numHit & "matches"
     -- display the titles
     -- if the user clicks the first title
     -- you can get the frame and movie from the
     --  first record in gCurrentResultSet
    -- etc
    end if
end

on getRecordsContaining pSearchString
  global gDatabaseList
  resultList = []
  recordCount = gDatabaseList.count
  repeat with i = 1 to recordCount
    record = gDatabaseList[i]
    if record.text contains pSearchString then
      resultList.append(record)
    end if
  end repeat
  return resultList
end

and so on.

If there is a lot of text, it may take to much RAM to store all the text in
a list. In this case, the searchList would just contain references to the
text members and you would have to search the text of the members. This may
be slower, I'm not sure. Have an experiment.

Luke




[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