当前位置: 主页 > 平面设计 > 【Director教程】属性列表应用一则

【Director教程】属性列表应用一则

  • 2022-01-23
  • 来源/作者: Ps123.Net    / 佚名    
  • 5 次浏览

(只是想为多媒体的发展尽一份力。以下是翻译director online 上的一篇关于属性列表的文章,觉得简单有用,所以给大家共享。动机单纯。-------alalala)


  问题
  我需要做一个分类搜索引擎,应用于我的数据列表。列表大概如下:


gdatalist=[[#name:”amanda”,#surname:”allard”,#department:”banking”,#phone:”7777”],_
[#name:”peter”,#surname:”jedrasicak”,#department:”b.i.s”,#phone:”7014”],[#name:”_
neil”,#surname:”cooper”,#department:”marketing”,#phone:”7012”]]

  用户需要填写姓名,然后用搜索键搜索。

  回答
  首先,我把荣誉归给Tab Julius 的书《lingo!》,它教会了我关于lists的知识。这是一本非常不错的书。

  对列表进行分类会使搜索速度加快。一旦进行分类,它就会保留这种性质。窍门在于创建一个有用的索引。

  对你的列表进行分类,你需要做一个复合列表并保证编入列表的数据的索引名称具有唯一性。注意,一旦编好搜索规则你就不能临时改变。所以,用名(first name)来做索引是一个坏的选择,因为可能会出现两个同名的人。用姓(last name)来做选择也不是一个好主意,因为你还是不能保证数据的唯一性。
 
  让你的用户同时输入名(first name)和姓(last name),我假定这样做会保证是唯一的数据------考虑如果在同一办公室出现同名同姓的人,一定会做一下区别(figuring that if there is a coincidence of names at an office one of the \"Bill\"s would be listed as a William.)。我们将用名(first name)和姓(last name)来做索引,将他们转换为复合的记号。如下


set gdatalist=[#jonesbill:[#name:”bill”,#surname:”jones”,#dept:”executive”,#phone:”_
7777”], #AllenWendy:[#name: \"Wendy\", #surname: \"Allen\", #dept: \"Executive\", #Phone: \"_
1234\"], #JedrasicakPeter: [#name: \"Peter\", #surname: \"Jedrasicak\", #dept: \"BIS\", #Phone:_
\"7014\"]]

  现在,对列表排序,只需增加“sort gdatalist”.这会让列表按字母顺序排列,并且以后新增加的也是。


Sort gdatalist
Put gdatalist

  这样,列表就会按字母顺序排列。现在,如果你的用户分别在域“姓(last neme)”和域“名(first name)”输入姓(last name)=”jones”和名(first name)=”bill”,并且按下了搜索键


on mouseup
set comboname=the text of field “inputlast” & the text of field “inputfirst”
set lookup=symbol(comboname)

if voidp(findpos(gdatalist,lookup)) then
alert”此人不在数据库中”
else
set mydatalist=getaPRop(gdatalist,lookup)

put the name of mydatalist into field “displayname”
put the surname of mydatalist into field “displaysurname”

end if
end

  很快,是不是。
  注意,如果用户按下了enter或space或return,那将会影响到lookup事件。因此,用keydownscript来忽略他们。


On startmovie
Set the keydownscript to “filterspaces”
End

On filterspaces
Case the key of
“ ”,enter,return
dontpassevent
end case
end

  如果数据量太大,不妨试试v12database xtra(好象是付费的)。