关于PaxCompiler字符串注意的问题
来源:互联网 发布:床垫哪个品牌好 知乎 编辑:程序博客网 时间:2024/05/27 06:16
继续我的PaxCompiler游戏脚本创作,发现个问题,在PaxCompiler脚本里面定义一个类(不是主脚本),主脚本引用这个定义类的脚本,返回一个字符串, 这个字符串显示出来是乱码, 如果再主脚本里面定义,对话框显示出来就不是乱码,调试发现,PaxCompiler保存字符串为UTF8的模式,显示的时候调用UTF8ToString函数转换下显示:
unit Unit1;interfaceuses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, PaxRunner, PaxInterpreter, PaxCompiler, FMX.Controls.Presentation, FMX.StdCtrls;type TForm1 = class(TForm) PaxCompiler1: TPaxCompiler; PaxPascalLanguage1: TPaxPascalLanguage; PaxInterpreter1: TPaxInterpreter; Button1: TButton; Button2: TButton; PaxInterpreter2: TPaxInterpreter; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;{ TGameLogin }var Form1: TForm1; // TPersistentClassimplementation{$R *.fmx}uses PaxRegister ; procedure Msg(AsText:String) ; var List:TStrings ; begin List:=TStringList.Create ; try List.Text:=AsText ; List.SaveToFile('1.txt'); finally List.Free ; end; ShowMessage(UTF8ToString(AsText)); end;procedure TForm1.Button1Click(Sender: TObject);var i:Integer ;begin PaxCompiler1.Reset; PaxCompiler1.RegisterLanguage(PaxPascalLanguage1); PaxCompiler1.AddModule('1', PaxPascalLanguage1.LanguageName); PaxCompiler1.AddCodeFromFile('1','test.pas'); if PaxCompiler1.Compile(PaxInterpreter1, False, False) then begin PaxInterpreter1.Run ; PaxInterpreter1.SaveToFile('test.bin'); end else begin for I:=0 to PaxCompiler1.ErrorCount - 1 do ShowMessage(PaxCompiler1.ErrorMessage[I]); end;end;procedure TForm1.Button2Click(Sender: TObject);begin PaxInterpreter2.Resume ; PaxInterpreter2.LoadFromFile('test.bin'); PaxInterpreter2.Run ;end;procedure TForm1.FormCreate(Sender: TObject);begin RegisterTypeAlias(0,'LChar',_typeWIDESTRING); RegisterHeader(0,'procedure Msg(AsText:string) ;',@Msg) ;end;end.
脚本
uses GameLogin ;var Login:TGameLogin ; begin Login:=TGameLogin.Create ; Login.Show('delphi我最喜欢的编程语言...') ; end.
unit GameLogin;interface{ TGameLogin }type TGameLogin = class(TObject) private protected public procedure Show(AsText:string); constructor Create; destructor Destroy; override; published end;implementation{ TGameLogin }constructor TGameLogin.Create;begin inherited ;end;destructor TGameLogin.Destroy;begin inherited;end;procedure TGameLogin.Show(AsText:string) ;begin Msg(AsText) ; end ;end.
阅读全文
0 0
- 关于PaxCompiler字符串注意的问题
- PaxCompiler脚本编译的一些要注意的问题
- PaxCompiler脚本编译的一些要注意的问题
- c++中 关于字符串的一些需要注意的问题
- 关于JavaScript中替换字符串需要注意的问题
- 关于截图的注意问题
- 关于Timer的注意问题
- 关于sizeof注意的问题
- 关于DataGridView的数据源绑定字符串两个值得注意的问题
- python 字符串str需要注意的问题
- 字符串复制注意问题
- 关于Filter需要注意的问题
- 关于闭包要注意的几点问题
- 关于元器件选型需要注意的问题
- 关于libevent定时器使用注意的问题
- 关于Tomcat服务器的一些注意问题
- 关于发布代码注意的问题
- 关于宏需要注意的问题
- 阿里一面记录
- DVWA下的SQL注入
- SQL:将查询结果插入到另一个表的三种情况
- MySQL中如何使用布尔类型
- React-native View组件transform样式
- 关于PaxCompiler字符串注意的问题
- cmd命令行下运行不了.py文件,但是编译器运行没问题,报错MoudleFoundError
- OC语言学习23-Block在类中的应用
- **
- Tensorflow常用函数笔记
- 【CQOI2016】手机号码
- A
- 记FreeCodeCamp中遇到的题目--js
- Spark-SQL之DataFrame操作大全