NCF参数化建筑论坛

标题: 求救,关于rhinoscript101翻译本的内容 [打印本页]

作者: funnyplay    时间: 2010-2-12 12:53
标题: 求救,关于rhinoscript101翻译本的内容
求救,本人vb零基础
关于rhinoscript101翻译本里
那个6.1数组部分的那个script的例子不明白啊,有没哪位大侠能解释下那个循环里的内容是什么意思,看不懂啊

intcount=0
和后来有什么关系?还有整个循环的内容?这个脚本想要达到的效果?
谁能给个完整解释?
作者: cjsyzwsh    时间: 2010-2-13 11:32
vb有点基础比较好
6.1的例子只是选择并显示myfavourite物体的一个脚本,intcount是一个计数的值,script里面是用来计量到第几个最喜欢的东西,循环里面是一个选择过程,并且用一个str数组记录选择的物体,从而方便后面的print的过程。
intcount=0是初始值
脚本就是演示一下循环的使用,其它没有什么……
不知道明白了没有。
作者: kiwifly    时间: 2010-2-13 12:17
Sub MyFavouriteThings()  
  Dim strPrompt, strAnswer  
  Dim arrThings()  
  Dim intCount   '这之前的没什么好说的
  intCount = 0   ’初始化数据。因为这个程序是为了得到用户的favourite things,但又不能事先确定用户会有多少个favourite thing,所以就一项一项问。
'intcout = 0 也就是下面循环里的case 0的情况。
  Do  
   Select Case intCount  
    Case 0  
    strPrompt = "What is your most favourite thing?"  
    Case 1  
    strPrompt = "What is your second most favourite thing?"  
    Case 2  
    strPrompt = "What is your third most favourite thing?"  
    Case Else  
    strPrompt = "What is your " & (intCount+1) & "th most favourite thing?"    ’case else 由于前面有了case 0,1,2就三项情况了,这个至少是有第四种

                                                                               '情况下才会发生作用
    End Select  
  strAnswer = Rhino.GetString(strPrompt)         '得到本轮的答案并存在strAnswer这个容器里。  
   If IsNull(strAnswer) Then Exit Do             ’当这轮没得到答案也就stranswer为空的时候,退出循环
   ReDim Preserve arrThings(intCount)            '重新声明arrThings(),中间的preserve是在不破坏当前数据的情况下重新定义数组的容量
  arrThings(intCount) = strAnswer                ’把前面的strAnswer存在ArrThings()的数组里。
  intCount = intCount+1                          '进入下一次循环
  Loop  
  If intCount = 0 Then Exit Sub                  ’intCount=0的情况是没有得到任务答案,所以退出
  Call Rhino.Print("Your " & UBound(arrThings)+1 & ’ favourite things are:")    ‘在得到答案的情况下,用print方法,在命令行里打印文字,下面的也  

   ‘好解了,就是把每一条都打印出来。
  For i = 0 To UBound(arrThings)  
   Call Rhino.Print((i+1) & ". " & arrThings(i))                           
  Next
End Sub


以前学过VB,现在基本不怎么会了。这个解释不知道能不能明白
作者: panhao1    时间: 2010-2-14 09:36
2# cjsyzwsh

我是明白了 不知道LZ明不明白




欢迎光临 NCF参数化建筑论坛 (http://www.ncf-china.com/) Powered by Discuz! X3.2