设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4867|回复: 6

[求助] Cursor,Cursor X和Cursor Y的使用

[复制链接]
发表于 2009-5-20 21:02:43 | 显示全部楼层 |阅读模式
5仿真币
对于黄家强ppt里面的一个程序,有点不懂。求教各位大虾!) P- i/ f% F6 h' U
(product:object):boolean
9 ], ~9 z+ M' x/ \8 Ois! k! K" D6 W2 ~9 ?2 b" f: V* ^
do5 f' e3 n4 u8 f+ z! G* k
partstatistics.cursorX:="color";
/ c- h, y- V( y% a partstatistics.cursorY:=1;
. h" u# ~. h- k3 i4 t if partstatistics.find(product.CurrIcon) then
* X8 _; E* C, \$ I; K  partstatistics["number",partstatistics.cursorY]:=8 v9 S9 |: Y' l3 [  S  V
  partstatistics["number",partstatistics.cursorY]+1;1 Y0 n6 B& m& \$ u2 ^$ g
  result:=true;
7 n9 u/ U$ F. T5 M* }3 ? else
# Q- D( E( \6 Y  result:=false;2 E! P" i) y( V* ^" m- q
end;
: S6 m1 P/ a, g7 ~8 |" w/ nend;% v/ R: p( N! N- T2 {) v

0 L- A$ l6 _" Y& C1 Q4 }# H. V“partstatistics.cursorY:=1;”
1 V9 r' B, x9 O, U9 p这一句怎么理解,他对partstatistics.cursorY赋值为1,那么后面的partstatistics["number",partstatistics.cursorY]不就变成了partstatistics["number",1],这样只能在number这一列的第一行里统计颜色的数量了。( w% u' J, U  v$ y. `5 E7 |- S7 ^
但它的结果是在五行里统计出各种颜色的数量。

附件: 您需要 登录 才可以下载或查看,没有帐号?注册
 楼主| 发表于 2009-5-20 21:12:27 | 显示全部楼层
还有CursorY在help的用法:1 R% U5 H9 l" E0 p( ]' x
Usage:  <path>.CursorY;  
3 B4 }* C7 y; y3 Y6 H8 r6 g
0 N  U4 V+ j: }* J8 nThe attribute CursorY sets the row in which the internal cursor is located. Note that all methods that employ ranges, such as find or max, use the current position of the cursor. Plant Simulation ignores ranges located before the current cursor position. The method starts its task beginning at the cursor position. If a method does not return the expected values, check the cursor position. The first column has the number 1. If you also want to include the customized index, set the attribute CursorY to 0. 9 a" ], x; s( z$ P9 K  _" ?3 J
4 U& H: n' r! v2 ]2 U8 r
This attribute applies to the TableFile and the TimeSequence.
1 n& [+ N9 D6 }
. P3 U+ o; `  T3 i: ~# o$ ], KYou can assign a value of type integer.
  S5 r. _: \: ~% N, l6 U# e/ W; e( ~6 Y2 C
Example:  is
8 I5 g8 l  b9 c* ?5 }+ O3 Pdo
+ K. g% Z! L- C3 ]+ _6 j9 U   tableFile.CursorX := 1; -- starting position# m9 A* h1 A) o/ h, W1 L
   tableFile.CursorY := 1; -- set
6 J$ t, `" [+ F! @if tableFile.find({1,*},4712) then
' t/ m. O6 k& v* H1 W. q1 h   print "found in row:",table.CursorY;9 G0 b% u  I2 R+ R: b4 n
end;  + Y7 f1 L. P6 x2 E% u: t
You can also set the pointer by employing a user-defined index. For a user-defined index of data type integer, use the method setCursor!
, \. X- k: S# p7 d3 @Example:  tableFile.CursorY := "urgent"; -- custom index
7 O$ m$ r# G7 o% g6 B4 Z1 PtableFile.CursorX := 3.1415;  3 t- e( ?+ f- o" a# M0 z% D3 v
有人能解释一下吗??我不是看得很懂,从他的例子里面print "found in row:",table.CursorY;这里明显不是他所说的tableFile.CursorY := 1。# w( v+ `: W8 |
我的理解就是程序对tableFile.CursorY 赋值为1了,为什么tableFile.CursorY 后面这个值会变?
: f1 K' b* Y2 N: L+ E还有tableFile.CursorX := 3.1415这个为小数又是表示什么意思啊?
 楼主| 发表于 2009-5-21 14:59:28 | 显示全部楼层
请问有人能解答吗?
发表于 2009-5-22 16:08:44 | 显示全部楼层
这个不难,你的注意力被转移了,主要研究研究find这个命令你就明白了,而不是cursor的问题
 楼主| 发表于 2009-5-23 03:24:53 | 显示全部楼层
哦~~
' g+ n- E$ i( X+ l+ f- f我看了,我大概理解了,such as find or max, use the current position of the cursor.
* j0 C0 ?9 l$ D  F* [* |When it finds a value, the method returns true and sets the cursor onto that cell.: `8 G4 N9 e9 L+ x
partstatistics.cursorY:=1只是说明了,光标在第一行,而当partstatistics.find(product.CurrIcon)找到product.CurrIcon里面的名字与partstatistics里面名字相符的时候,光标就会设置在partstatistics里面相应的行那里,例如如果找到blue时,光标就移到partstatistics里面["number",partstatistics.cursorY]地方,这里的partstatistics.cursorY就是blue这一行的行数,就是第二行,number那一列。这么说,partstatistics.cursorY这数是随着find这条语句找到的位置而变化的。
6 c- v8 ~: W8 P2 f8 o5 J, g6 _5 \9 x不知道我这样理解有没有错呢?. _8 z; L5 b& G
请大家指教一下!
4 L9 _( @% o6 Z* `7 W% `5 k谢谢!
发表于 2009-5-23 09:05:22 | 显示全部楼层
正解
 楼主| 发表于 2009-5-23 18:49:25 | 显示全部楼层
谢谢,我现在懂了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2024-5-29 11:07 , Processed in 0.015003 second(s), 12 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表