
-->Am 11:11 的相册 <-- -->Am 11:11 的网上硬盘<--
PureBasic 第2节 控制台
filename:Konsolen.pb
; /////////////////////////////
; AmLinger
; by 2008 02 05
; /////////////////////////////
; 将英文站点的一些代码注释一下.
; 新手可以进步更快
; 用PureBasic写一个控制台程序
;打开控制台模式
OpenConsole()
;设置控制台标题
ConsoleTitle("Hello PureBasic Console")
;打印一个HELLO WORLD 嘿嘿.习惯
Print("Hello World")
;延时6000毫秒
Delay(6000)
;换行打印
PrintN("Welcome to PureBasic")
Print("Print PrintN 区别")
;关闭控制台. 当然也可以不用它,
;要有一个好的习惯,打一个设备时,最后一定要关闭.
CloseConsole()
;OK 第一个就自注释完了.很容易吧. ^_^
filename:KonsolenII.pb
; /////////////////////////////
; AmLinger
; by 2008 02 05
; /////////////////////////////
; 将英文站点的一些代码注释一下.
; 新手可以进步更快
; 用PureBasic写一个控制台程序
OpenConsole()
;原代码中没有下面这一句 这一句是我自己加的.
;因为要使用 ConsoleLocate 定位函数 在 4.1 版本以上
;首要要开启图形模式才可以正常
EnableGraphicalConsole(#True)
ConsoleTitle("定位输出")
;定位输出
ConsoleLocate(35,0)
;
PrintN("嗨")
ConsoleLocate(30,10)
Print("请把你的名字写在这里好吗?(以回车结束): ")
;接收控制台输入内容,以回车结束
Name$ = Input()
;清除之前屏幕显示,也必须在开启图形模式之后才可以正常工作
ClearConsole()
ConsoleLocate(30,10)
Print("哇喔 "+Name$+" 这个名很不错哟.")
;延时3000毫秒
Delay(3000)
CloseConsole()
filename:KonsolenIII.pb
; /////////////////////////////
; AmLinger
; by 2008 02 05
; /////////////////////////////
; 将英文站点的一些代码注释一下.
; 新手可以进步更快
; 用PureBasic写一个控制台程序
;原代码中,这一个是空的,所以决定写一点什么..
;这个程序中用 Delay(3000) 延时3000 毫秒后退出
;这里我们模拟用C中的Getch() 请按任意键退出
Declare Getch()
OpenConsole()
;原代码中没有下面这一句 这一句是我自己加的.
;因为要使用 ConsoleLocate 定位函数 在 4.1 版本以上
;首要要开启图形模式才可以正常
EnableGraphicalConsole(#True)
ConsoleTitle("定位输出")
;定位输出
ConsoleLocate(35,0)
;
PrintN("定位测试")
ConsoleLocate(30,10)
Print("请把你的名字写在这里好吗?(以回车结束): ")
;接收控制台输入内容,以回车结束
Name$ = Input()
;清除之前屏幕显示,也必须在开启图形模式之后才可以正常工作
ClearConsole()
ConsoleLocate(30,10)
PrintN("哇喔 "+Name$+" 这个名很不错哟.")
;延时3000毫秒
;Delay(3000)
Getch()
CloseConsole()
Procedure Getch()
Print("请按任意键退出...")
Repeat
Key$=Inkey()
Until Key$
EndProcedure
比如写了个hello.exe
在cmd下 用hello.exe xxx
怎样让hello.exe 接收到xxx呢?
Procedure Getch()
Print("请按任意键退出...")
Repeat
Key$=Inkey()
Until Key$
EndProcedure
Result = OpenConsole()
;CountProgramParameters 获取尾部参数的个数
;ProgramParameter 获取尾部参数
;ProgramParameter(index) 获取指定位置的参数
For k = 0 To CountProgramParameters()-1
Print("参数")
Print(StrD(k))
Print(":")
PrintN( ProgramParameter(k))
Next
Getch()
CloseConsole()
;测试
;hello.exe 参数一 参数二 参数三...
; IDE Options = PureBasic 4.20 (Windows - x86)
; CursorPosition = 18
; FirstLine = 12
; Folding = -
; EnableXP
; Executable = hello.exe




