UOL语言跟Java和C#类似,具有面向对象的特性。所有的变量和方法都写在class(类)中。如果你能在下载的文件夹中找到system.uol,string.uol文件,那么你可以通过串口来显示输出内容。下面是你的第一个程序:
public class hello
{
public
static void main()
{
//创建system对象
system sys = new system();
//串口输出hello world
sys.printString(“hello
world”);
//无限循环
while(1)
{
}
}
}
由于测试版编译器暂时还不支持静态类,所以system内的调用需要创建对象。
程序写好后,打开命令窗口,进入uol.exe所在路径,如图
:
输入uol,回车。如果程序没有语法错误,则有如下提示:
如果代码有错误,编译器会报错,如图:
例如去掉system sys
= new system();
编译之后,文件夹内会有output.bin文件。 |