用Free Pascal IDE编写第一个程序Pascal版的hello world

首先Free Pascal IDE必须下载32位的,64位的没有fp.exe不能打开IDE界面。

下载地址:http://www.freepascal.org/download.var

安装过程这里就免了。直接进入正题。

1.解决欢迎界面乱码

双击桌面Free Pascal IDE图标打开

出现乱码

用Free Pascal IDE编写第一个程序Pascal版的hello world_第1张图片

这个乱码可以通过将编码从936改成437来解决。方法如下

标题栏--鼠标 右键--默认值

用Free Pascal IDE编写第一个程序Pascal版的hello world_第2张图片

点击默认代码页的下拉箭头,选择437

用Free Pascal IDE编写第一个程序Pascal版的hello world_第3张图片

关掉窗口,重新打开,就不再是乱码了。

用Free Pascal IDE编写第一个程序Pascal版的hello world_第4张图片

2.编写一个程序

File-->open(文件-->打开,这里可以用鼠标直接点,也可以用键盘,对应的键盘操作为Alt+F-->N(菜单项中的变色字母,或者上下键移动回车))

用Free Pascal IDE编写第一个程序Pascal版的hello world_第5张图片

用Free Pascal IDE编写第一个程序Pascal版的hello world_第6张图片

这里会自动新建一个noname01.pas的程序文件

下面打代码就好了。

用Free Pascal IDE编写第一个程序Pascal版的hello world_第7张图片

下面保存,运行之前需要先保存,File-->Save,在弹出的对话框中Name填hello,然后点OK

用Free Pascal IDE编写第一个程序Pascal版的hello world_第8张图片

用Free Pascal IDE编写第一个程序Pascal版的hello world_第9张图片

用Free Pascal IDE编写第一个程序Pascal版的hello world_第10张图片

用Free Pascal IDE编写第一个程序Pascal版的hello world_第11张图片

可以看到noname.pas变成了hello.pas

用Free Pascal IDE编写第一个程序Pascal版的hello world_第12张图片

3.运行程序与查看结果

运行可以通过菜单Run-->Run运行,也可以通过快捷键Ctrl+F9运行

用Free Pascal IDE编写第一个程序Pascal版的hello world_第13张图片

编译失败

用Free Pascal IDE编写第一个程序Pascal版的hello world_第14张图片

仔细检查发现是writen写错了,正确的应该是writeln

Esc退出,然后重新编辑保存运行。编译成功会看到下面的黑框一闪而过。

用Free Pascal IDE编写第一个程序Pascal版的hello world_第15张图片

我们可以通过Debug-->User screen(Alt+F5)查看运行结果

用Free Pascal IDE编写第一个程序Pascal版的hello world_第16张图片

结果如下,前几次的结果也会显示出来。

用Free Pascal IDE编写第一个程序Pascal版的hello world_第17张图片

当然我们也可以通过上一节的加readln;  语句来看结果


附:

本文用到的代码

program hello;
begin
  writeln ('Hello, World.')
end.

本文参考

1.Compilers/zh CN,http://wiki.freepascal.org/Compilers/zh_CN



你可能感兴趣的:(编程)