我正在研究delphi 7,我正在研究一个字符串,我遇到了这个
对于一个默认长度的字符串,即简单地声明为字符串,max size始终为255.永远不允许ShortString增长到超过255个字符.
一旦我必须在我的delphi代码中做这样的事情(这是一个非常大的查询)
var
sMyStringOF256characters : string;
ilength : integer;
begin
sMyStringOF256characters:='ThisStringisofLength256,ThisStringisofLength256,.....'
//length of sMyStringOF256characters is 256
end;
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
[错误] u_home.pas(38):字符串文字最多可包含255个元素.
但是当我试试这个
var
iCounter : integer;
myExtremlyLongString : string;
begin
myExtremlyLongString:='';
Label1.Caption:='';
for iCounter:=0 to 2500 do
begin
myExtremlyLongString:=myExtremlyLongString+inttostr(iCounter);
Label1.Caption:=myExtremlyLongString;
end;
Label2.Caption:=inttostr(length(myExtremlyLongString));
end;
Run Code Online (Sandbox Code Playgroud)
结果是
如您所见,myExtremlyLongString的长度为8894个字符.
为什么delphi没有给myExtremlyLongString提供长度超过255的错误?
编辑 我用过
SetLength(sMyStringOF256characters,300);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我无法弄清楚如何使用FastMM.我从SourceForge下载了它,并将FastMM4Messages.pas和FastMM4.pas放在我的dpr文件的顶部.
我现在调用此过程来泄漏一些内存:
procedure testMemoryFastMM;
var
str : TStringList;
begin
str:=TStringList.Create;
str.add('MemChk');
str.SaveToFile('C:\leeMemChk.txt');
end;
Run Code Online (Sandbox Code Playgroud)
并得到这个消息
如何启用这些FullDebugMode和LogMemoryLeakDetailsToFile开关?
我正在开发一个应用程序,其中我有一个具有长文本值的组合框.由于文本值很大(以字符... 20或更多),要在组合框中显示,要求是first
在选择后显示在字符上从下拉.就像用红色标记的图像一样.如果用户选择第3项,3 0.5 to 1.25 Slight
我应该只3
在组合框中显示.
所以我试过这个
sTheSelectedValue : string;
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
sTheSelectedValue:=TrimTextAndDisplay(ComboBox1.Text); //send theselected value
ComboBox1.Text :=''; //clear the selection
ComboBox1.Text:=sTheSelectedValue; //now assign as text to combo box
Button1.Caption:=ComboBox1.Text; //just show the new value on the button.
end;
function TForm1.TrimTextAndDisplay(TheText : string): string;
var
sTheResult : string;
begin
sTheResult :=copy(TheText,0,1); //extract the first value..
Result :=sTheResult;
end;
Run Code Online (Sandbox Code Playgroud)
结果是
按钮似乎显示正确的值,但不显示组合框.
我想要的是进入3
组合框,我似乎无法设置ComboBox1.Text:=
任何人告诉我该怎么做?像这样从组合框中选择结果应该是
我正在使用Postgres 9.0,并且有一个需要在其中将图像插入远程的应用程序server
。所以我用:
"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.12 -p 5432 -d myDB -U my_admin -c "\lo_import 'C://im/zzz4.jpg'";
Run Code Online (Sandbox Code Playgroud)
哪里
192.168.1.12
是服务器系统的IP地址
5432
是端口号
myDB
是服务器数据库名称
my_admin
是用户名
"\lo_import 'C://im/zzz4.jpg'"
是触发的查询。
将图像插入数据库后,我需要像这样更新表中的一行:
UPDATE species
SET speciesimages=17755; -- OID from previous command.. how to get the OID ??
WHERE species='ACCOAA';
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:如何在psql中得到OID
返回值\lo_import
?
我尝试\lo_import 'C://im/zzz4.jpg'
在Postgres中运行,但出现错误:
ERROR: syntax error at or near ""\lo_import 'C://im/zzz4.jpg'""
LINE 1: "\lo_import 'C://im/zzz4.jpg'"
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
update species
set speciesimages=\lo_import 'C://im/zzz4.jpg'
where species='ACAAC04';
Run Code Online (Sandbox Code Playgroud)
但是我得到这个错误:
ERROR: …
Run Code Online (Sandbox Code Playgroud) 我正在使用Delphi 7
和Delphi 2006
正在开发一个项目,我正在开发一个可以获得某些系统信息的组件.现在要求是在系统上安装组件之后,IDE上应该有一个菜单项,如下所示
而对于delphi 7
这样的
我搜索过关于添加菜单项的网,但我没有得到任何东西,项添加到IDE
喜欢的一个EurekaLog
了.任何人都可以告诉我如何添加项目EurekaLog
或mysql
?它是在注册表中的某些地方吗?
我在工作的组件上Delphi 7
和Delphi 2006
,在那里我使用,我需要添加到一个单元.dpr
上的组件自动删除该项目的文件.就像Eureka Log自动将单元'ExceptionLog'添加到项目文件中一样:
当我将组件放在项目中的任何表单上时,有人能告诉我如何以编程方式将单元添加到项目文件中吗?
我想使用批处理文件创建Postgres数据库.现在这样做的正常方法如下:
"C:\ Program Files\PostgreSQL\9.0\bin\createdb.exe"-U Myadmin MydatAbseName
上面的脚本使用默认数据库参数创建数据库.但是,我想创建一个包含以下参数的数据库,如下所示:
WITH OWNER = Myadmin
TEMPLATE = template0
ENCODING = 'SQL_ASCII'
TABLESPACE = pg_default
LC_COLLATE = 'C'
LC_CTYPE = 'C'
CONNECTION LIMIT = -1;
Run Code Online (Sandbox Code Playgroud)
请告诉我如何使用批处理文件使用上述参数创建数据库.
另请告诉我如何使用.sql文件执行相同的操作,例如此命令行:
"C:\Program Files\PostgreSQL\9.0\bin\createdb.exe" -U Myadmin -f C:\createDB.sql;
Run Code Online (Sandbox Code Playgroud) 我正在使用delphi 7处理应用程序,我刚刚遇到了这个问题
{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
unit fmMain; // this is the main form of the project
interface
uses
//..all the code is here
end.
Run Code Online (Sandbox Code Playgroud)
我知道有这些Compiler Directive和Delphi Compiler Directives列表
代码的作者在主单元名称之前放置了如此多的编译器指令.
任何人都可以告诉我
我正在研究delphi 7,我想如何将TpaintBox的内容复制/分配给Tbitmap?
像这样
public
{ Public declarations }
BitMap : TBitmap;
end;
Run Code Online (Sandbox Code Playgroud)
我有一个声明为公共的Tbitmap,我就像这样创建onFormCreate
procedure TForm1.FormCreate(Sender: TObject);
begin
BitMap := TBitMap.Create;
end;
Run Code Online (Sandbox Code Playgroud)
然后我像这样在位图上绘制一些东西
procedure TForm1.DrawOnPainBox;
begin
If BitMap.Width <> PaintBox1.Width then BitMap.Width := PaintBox1.Width;
If BitMap.Height <> PaintBox1.Height then BitMap.Height := PaintBox1.Height;
BitMap.Canvas.Rectangle(0,0,random(PaintBox1.Width ),random(PaintBox1.Height));
PaintBox1.Canvas.Draw(0,0,BitMap);
end;
Run Code Online (Sandbox Code Playgroud)
与PaintBox1.Canvas.Draw(0,0,BitMap);
我们可以显示的内容有位图中的颜料盒,但什么是相反的呢?
如何将一个paintbox的内容分配/复制到位图?
`BitMap:=PaintBox1.Canvas.Brush.Bitmap;`
Run Code Online (Sandbox Code Playgroud)
这编译,但如果我这样做,再次调用procedure TForm1.DrawOnPainBox;
我得到access Violation
和调试器显示bitmap
,PaintBox1.Canvas.Brush.Bitmap
即使有一些线条绘制在paintBox
我正在开发AA成分delphi 7
和delphi 2006
,组件使用.pas
(不矿)文件这需要一个DLL
文件是存在于应用程序目录.
可以将DLL
文件嵌入到组件中,这样当用户将其放在表单上或在运行时创建它时,DLL
它将被放在应用程序目录中吗?
目前
1)我告诉用户将DLL
文件放在应用程序目录中.
2)DLL
在参考资料中添加文件,这样在创建时,我可以将其DLL
放入应用程序目录中?来自delphidabbler_embed_resource.我已经完成了使用
{Drop the Resource..!!!}
procedure DropDllToApplicationDirectOry(applicationPath : string);
var
RS: TResourceStream;
begin
// Create resource stream
RS := TResourceStream.CreateFromID(HInstance, 100, RT_RCDATA);
try
// applicationPath : example c:\MyTestProject Lee\
if DirectoryExists(applicationPath) then RS.SaveToFile(applicationPath+'myDllFileWhichIsNeeded.dll')
finally
// Free the stream
RS.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这DropDllToApplicationDirectOry
把资源从{$RmyDllFileWhichIsNeeded.dll.RES}
和drope带到了位置但是
DropDllToApplicationDirectOry
当我将组件放在表单上时,如何调用此方法?
我尝试initialization
了组件但DLL没有复制,所以我得到错误
编辑 对 …
delphi ×8
delphi-7 ×6
delphi-2006 ×3
batch-file ×2
postgresql ×2
cmd ×1
combobox ×1
database ×1
ddl ×1
draw ×1
fastmm ×1
memory-leaks ×1
menuitem ×1
opentools ×1
size ×1
string ×1
toolsapi ×1