r2 - 07 Nov 2007 - 13:42:33 - WhaleForestYou are here: TWiki >  Processing Web > ProcessingHandbookChinese > Structure1CodeElementsConsole

Console 控制台

软件的运行速度是如此之快以至于我们无法用眼睛观察到,但是了解程序在电脑里到底是怎么运行的对我们来说又非常重要,所以print()和printin()函数的功能就是使运行信息在视觉窗口中呈现出来。print()函数不等同于浏览器中具打印功能的快捷按钮,而是发送数据到控制台,用来呈现变量,确认事件,及外部信号的接收程度。目前来看其定义不好理解,但随着课程深入我们将越来越了解它的意义,就象注释一样,print()和printin()函数都会帮助我们更加有效测试,修改程序。

// To print text to the screen, place the desired output in quotes 
println("Processing...");  // Prints "Processing..." to the console 
// To print the value of a variable, rather than its name, 
// don’t put the name of the variable in quotes 
int x = 20; 
println(x);  // Prints "20" to the console 
// While println() moves to the next line after the text 
// is output, print() does not 
print("10"); 
println("20");  // Prints "1020" to the console 
println("30");  // Prints "30" to the console 
// The "+" operator can be used for combining multiple text 
// elements into one line 
int x2 = 20; 
int y2 = 80; 
println(x2 + " : " + y2);  // Prints "20 : 80" to the message window
    
1-07
Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback