51Testing软件测试论坛

标题: 求助:新手提几个肤浅问题 [打印本页]

作者: noahlish    时间: 2007-4-30 15:33
标题: 求助:新手提几个肤浅问题
1.function temp1(){}能定义函数么?public function temp1(){}又如何?他们有什么区别?
2.从1、2、3、4中随机取一个数,可以写为:random(4)么?如果不是,该怎么写?
3.打印消息窗口脚本该怎么写?C语言可以用printf打印消息,flash中AS语言可以用trace()调试,那TSL是如何打印消息的?
4.TSL有语法检查功能么?写脚本难免会出现手误
5.说明书中的实例中:
     If(tickets*price==total)
     tl_step(“total”,0,”total is correct.”)
  为何一回放就会提示:undefined function call t1_step("total",0,"Total is correct.");
作者: dionysus    时间: 2007-4-30 23:40
1. 可以定义函数,他们的作用域不同:
A user-defined function has the following structure:
[class] function name ([mode] parameter...)
{
declarations;
statements;
}
The class of a function can be either static, public or external.
A static function is available only to the test or module within which the
function is defined.
Once you execute a public function, it is available to all tests, for as long as
the test containing the function remains open (until you manually click the
Stop button).
An external function behaves like a public function, except that while its
declaration is in the local test or compiled module, its implementation code
resides in an external source.
2. lz可以使用rand()函数来得到随即数,但这是一个伪随即数,可以结合srand()函数使用,参考:
srand(2);
for(i=1;i<=5;i++)
{
arand = int(rand()*10);
report_msg(arand);
}
3. 不知道lz说的打印消息是怎样打印,WR中可以使用report_msg()或者tl_step()等函数向test result中写结果
4. 以WR8.2为例,Tools->Syntax Check可以检查简单的函数错误,但错误检查功能并不强大
5. 函数为tl_step,这里是字母 l 不是数字 1
作者: noahlish    时间: 2007-5-8 09:43
多谢版主,太好了
作者: wangpu160000    时间: 2007-6-3 12:02
路过,学习
作者: whyan02002    时间: 2008-2-5 17:58
谢谢,我也碰到类似的问题,看了各位高人的指点,OK了




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2