我打算在我的应用程序中包含一个pascal脚本.它不需要任何Web访问,只需访问我的应用程序中的类.应该快速(编译).我看到有许多脚本可用,有些是解释器,但在编译器中RemObjects pascal脚本和Delphi Web脚本(DWS)似乎是强大的并且积极地追求.
请问有人可以提出一个优点吗?谢谢
我不是Pascal新手,但直到现在我仍然不知道为什么Delphi和Free Pascal通常声明参数并将值返回为有符号整数,而我看到它们应该始终是正数.例如:
Pos()返回Integer的类型.有可能成为负面的吗?SetLength()将NewLength参数声明为Integer的类型.字符串是否有负长度?System.THandle宣称为Longint.手柄有负数吗?有许多决定,如Delphi和Free Pascal.这背后有什么考虑因素?
我需要用Pascal/Delphi/Lazarus编写的逆透视变换.见下图:

我想我需要遍历目标像素,然后计算源图像中的相应位置(以避免舍入错误等问题).
function redraw_3d_to_2d(sourcebitmap:tbitmap, sourceaspect:extended, point_a, point_b, point_c, point_d:tpoint, megapixelcount:integer):tbitmap;
var
destinationbitmap:tbitmap;
x,y,sx,sy:integer;
begin
destinationbitmap:=tbitmap.create;
destinationbitmap.width=megapixelcount*sourceaspect*???; // I dont how to calculate this
destinationbitmap.height=megapixelcount*sourceaspect*???; // I dont how to calculate this
for x:=0 to destinationbitmap.width-1 do
for y:=0 to destinationbitmap.height-1 do
begin
sx:=??;
sy:=??;
destinationbitmap.canvas.pixels[x,y]=sourcebitmap.canvas.pixels[sx,sy];
end;
result:=destinationbitmap;
end;
Run Code Online (Sandbox Code Playgroud)
我需要真正的公式......所以OpenGL解决方案并不理想......
我对编程世界相对较新.我有一些性能问题:
控制台应用程序比具有图形用户界面的应用程序运行得更快
像C和Pascal这样的语言比C++和Delphi这样的面向对象语言更快吗?我知道语言速度更多地依赖于编译器而不是语言本身,但是程序语言的编译器是否比OO编译器(包括可以生成C代码的C++编译器)产生更快的代码?
(我正在寻求Inno Setup脚本,但我的理解是[Code]部分使用Pascal语法,或者近似.我对Pascal或其标准惯例一无所知,所以请提前为我的无知道歉.)
在定义函数/过程的局部变量时,定义其初始值的语法不是这样的问题......
procedure MyProcedure();
var
aFlag: Boolean;
begin
aFlag := true;
.
.
.
end;
Run Code Online (Sandbox Code Playgroud)
但我很难弄清楚如何处理全局变量的初始值.例如,如果我想要一个全局布尔变量开始为true而不是false(默认值),我将如何实现它?
谢谢!
我在Delphi中创建了一个工具来创建彩虹表.直到文件增长到3.1 GB才好.我关闭了我的程序.然后我再次打开它,并在执行此代码时崩溃:
Assign(RainbowFile,'Rainbow_table.txt'); {assign a text file}
Append(RainbowFile);
Run Code Online (Sandbox Code Playgroud)
Delphi显示错误"提出的预期类EInOutError消息'I/O错误131'.我的问题:如何将数据附加到大于2 GB的现有文件.//已过时下一个问题:我目前有代码:
Content_to_file := (#13+#10+Start_string+':'+hexstr(GTA_San_Andreas_CRC32(Start_string), 8));
RainbowFile_handle.WriteBuffer( Content_to_file[1], Length(Content_to_file)*SizeOf(Char));
Run Code Online (Sandbox Code Playgroud)
如何摆脱Content_to_file变量.如果可能的话,我想把它直接放到WriteBuffer上.
编辑:
TFileStream适用于大于2 GB的文件.我现在测试了.但是可以这样写:
RainbowFile_handle.WriteBuffer( Start_string[1]+':',
Run Code Online (Sandbox Code Playgroud)
我的意思是不传递变量参数.或者我确实传递了变量的第一个字符?
编辑2:
我目前这样做了:
Content_to_file := (#13+#10+Start_string+':'+hexstr(GTA_San_Andreas_CRC32(Start_string), 8));
RainbowFile_handle.WriteBuffer( Content_to_file[1], Length(Content_to_file)*SizeOf(Char));
Run Code Online (Sandbox Code Playgroud)
没有这个变量可以做到吗?
我可以使用Delphi中的内置方法处理大量数据(超过10 ^ 400)吗?
我正在尝试编写将枚举转换为字符串并再次返回的函数.
即:
TConversions = class
strict private
public
class function StringToEnumeration<T:class>(x:String):T;
class function EnumerationToString<T:class>(x:T):String;
end;
Run Code Online (Sandbox Code Playgroud)
在我的实施部分
uses
System.TypInfo
;
class function TConversions.StringToEnumeration<T>(x:String):T;
begin
Result := T(GetEnumValue(TypeInfo(T), x));
end;
class function TConversions.EnumerationToString<T>(x:T):String;
begin
Result := GetEnumName(TypeInfo(T), integer(x));
end;
Run Code Online (Sandbox Code Playgroud)
问题是,枚举不是T:classpascal中的类型.我也不能用T:record.
帕斯卡可以做到这一点吗?
在delphi 2009中,我引用了一个IInterface我想要转换为底层的东西TObject
使用TObject(IInterface)显然在Delphi 2009中不起作用(它应该在Delphi 2010中工作)
我的搜索引导我找到一个应该做的技巧,但它对我不起作用,当我尝试在返回的对象上调用方法时,我得到了AV.
我无法真正修改类,我知道这打破了OOP
我正在为Delphi寻找一个好的免费脚本引擎.我想为应用程序添加脚本,以便我可以编写小的测试脚本.具体来说我需要:
我不需要全面的语言支持,只需要基础知识.我看到了这个:https://stackoverflow.com/questions/226135/scripting-library-for-delphi但是我假设事情已经发生了一些变化.
我想要做的就是在我的程序中添加一个备忘录组件,并在运行时向备忘录添加一个源代码片段,然后单击一个go按钮.我希望脚本能够访问我的应用程序的变量和函数.
实现这一目标的最简单方法是什么?示例程序如下.
program Project31;
uses
Forms,
Unit36 in 'Unit36.pas' {Form36};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm36, Form36);
Application.Run;
end.
Run Code Online (Sandbox Code Playgroud)
.
unit Unit36;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm36 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form36: TForm36;
implementation
{$R *.dfm}
procedure RoutineInMyApplication ;
begin
ShowMessage ('Hello from my Application') …Run Code Online (Sandbox Code Playgroud) pascal ×10
delphi ×9
bignum ×1
c ×1
c++ ×1
casting ×1
delphi-2009 ×1
dwscript ×1
file ×1
freepascal ×1
generics ×1
geometry ×1
inno-setup ×1
interface ×1
lazarus ×1
math ×1
performance ×1
remobjects ×1
scripting ×1