这个游戏是一个高级术语书中的单词搜索游戏,而术语代码使用的是cc,这是一个代码错误。到底出了什么问题,还是cc的使用已经过时了?如果是这样的话,如何纠正呢?
on getPropertyDescriptionList me
list = [:]
-- the text member with the words in it
addProp list, #pWordSource,[cc]
[#comment: "Word Source",[cc]
#format: #text,[cc]
#default: VOID]
addProp list, #pEndGameFrame,[cc]
[#comment: "End Game Frame",[cc]
#format: #marker,[cc]
#default: #next]
return list
end发布于 2015-03-11 16:34:06
我猜这是来自here的代码,对吧?
这看起来像是Lingo语法的旧版本。显然,[cc]代表“连续字符”。它基本上使编译器忽略紧随其后的换行符,因此它将从[#comment:到#default: VOID]的所有内容都看作是一行,这在语法上是正确的。
如果我没记错的话,很久很久以前,那些制作Lingo的家伙又做了一个疯狂的决定,让连续字符看起来像这样:¬当然,这并没有在很多地方打印出来,所以像你的书这样的一些文本使用了像[cc]这样的东西来代替。
在现代版本的Lingo中,连续字符是\,就像在C中一样。
发布于 2016-04-22 08:51:22
我在早期的director中编程,但在那之后的许多年里,我一直在学习其他语言。我理解这段代码。该函数尝试生成字典的字典。在准JSON中:
{
'pWordSource': { ... } ,
'pEndGameFrame': { ... }
}它创建一个字符串散列,然后存储一个"pWordSource“作为指向它自己的3项散列的新键。然后,系统用一个新的密钥"pEndGameFrame“重复该过程,提供另一个3项散列。所以为了展开椭圆。从上面的代码示例:
{
'pWordSource': { 'comment': 'Word Source', 'format': 'text', 'default': null } ,
'pEndGameFrame': { 'End Game Frame': 'Word Source', 'format': 'marker', 'default': 'next' }
}所以我希望这能解释散列字符。这是lingo的说法:“这不仅仅是一个字符串,它是一个特殊的特定于控制器的系统,我们称之为symbol。它可以用更传统的编程术语描述为一个常量。lingo编译器将用一个整数替换#string1,并且它总是与#string1关联的相同的整数。因为散列键实际上是整数而不是字符串,所以我们可以更改json模型,使其看起来更像这样:
{
0: { 2: 'Word Source', 3: 'text', 4: null } ,
1: { 2:'End Game Frame', 3: 'marker', 4: 'next' }
}其中:
0 -> pWordSource
1 -> pEndGameFrame
2 -> comment
3 -> format
4 -> default因此,为了模仿2016年的行话中的相同构造行为,我们使用较新的object oriented dot syntax for calling addProp on property lists。
on getPropertyDescriptionList me
list = [:]
-- the text member with the words in it
list.addProp(#pWordSource,[ \
#comment: "Word Source", \
#format: #text, \
#default: void \
])
list.addProp(#pEndGameFrame,[ \
#comment: "End Game Frame", \
#format: #marker, \
#default: #next \
])
return list
end同样,相同的参考展示了如何使用方括号来“访问”属性,然后通过设置它们的第一个值来初始化它们。
on getPropertyDescriptionList me
list = [:]
-- the text member with the words in it
list[#pWordSource] = [ \
#comment: "Word Source", \
#format: #text, \
#default: void \
]
list[#pEndGameFrame] = [ \
#comment: "End Game Frame", \
#format: #marker, \
#default: #next \
]
return list
end如果您仍然对反斜杠的作用感到困惑,还有其他方法可以使代码更垂直。
on getPropertyDescriptionList me
list = [:]
-- the text member with the words in it
p = [:]
p[#comment] = "Word Source"
p[#format] = #text
p[#default] = void
list[#pWordSource] = p
p = [:] -- allocate new dict to avoid pointer bug
p[#comment] = "End Game Frame"
p[#format] = #marker
p[#default] = #next
list[#pEndGameFrame] = p
return list
end

上面的截图显示了它在OS X Yosemite上的Director12.0中工作。
https://stackoverflow.com/questions/28964336
复制相似问题