ERRORR MESSAGE GOT ANSISTRING EXPECTED SHORTSTRING
Hello! Who an help me? I get the following error message in gimages.pp in line 271: Error: call by var parameters have to match exactly: Got ANSISTRING expected SHORTSTRING function LoadImage( Dir, FileName: string; var P: PImageCanvas; DesiredBPP: Word ): Boolean; var Dirr,Name,Ext: string; R: PImageReader; S: PStream; begin FSplit( FileName, Dirr, Name, Ext ); // here i get the error FileName := FSearch( FileName, Dir+';'+Dirr+';'+'.\'); if FileName = '' then begin P := nil; The {$H+} directive brings no success. I tried two methods: 1.) var {$H+} Dirr,Name,Ext: string; {$H-} no success. I get the same error message. 2.) I gave the {$H+} directive before LoadImage() function. After LoadImage() function i gave {$H-} directive. no success. I get the same error message. What goes wrong here? Thanks alredy for your help!
-- Thomas Sch ö nfelder,2007 년 11 월 22 일 10:48 오후
(E-mail)
답:
> Thanks alredy for your help! I hope this doesn't mean you aren't going to post a reply after someone helps. If the original poster doesn't reply after help is given, the person who helped has no idea whether his answer was read by the o.p. {$H+} is very cryptic; I had to look it up. {$longstrings on} is easier to understand. I had to look up "fsplit" also, but I didn't know which unit to look in. Using "dos.fsplit" would help readers of your program, especially since you left out the "uses dos" in the fragment above. Does the compiler directive {$longstrings on} or {$h+} appear anywhere else in your program? That would seem to be the problem. If so, you want to turn longstrings off (not on with {$h+}) when defining the function load_image. In the future, please show all compiler directives and "uses" that could affect the code that you post. This works for me:
{$longstrings on}
uses dos;
{$longstrings off}
procedure show_parts( file_name: string );
var dir,name,ext: string;
begin
dos.fsplit( file_name, dir, name, ext );
writeln( dir );
writeln( name );
writeln( ext );
end;
{$longstrings on}
var
path: string;
begin
path := 'c:\here\foo.bar';
show_parts( path );
end.
Note that if the variable "path" is longer than 255 characters, only the first 255 charcters will be received by the procedure "show_parts", since its parameter is a short string. Another way to make sure that a string variable is a short string, not an ansistring, is to specify a maximal size: var dir,name,ext: string[255];
-- Steve Fisher,2007 년 11 월 23 일 01:47 오전
(E-mail)
I noticed that it's possible to typecast
ansistring
to shortstring
. Try this: FSplit( shortstring(FileName), shortstring(Dirr), shortstring(Name), shortstring(Ext) );
-- Mario Ray Mahardhika,2007 년 11 월 23 일 05:54 오전
(E-mail)
Hello! @Steve: Thank's for your help. To parenthise the used dos unit with the longstrings on/ff directive works for me. @Mario: The other version, the typecast to shortstring brings me the error message ...different type size (4 -> 256). Only the Steves version works for me. In spite of this, thank you too. You see, my "Thank's alredy for your help" doesn't mean that i don't replay an answer. I whish you both a nice weekend. Thomas
-- Thomas Sch ö nfelder,2007 년 11 월 23 일 10:59 오전
(E-mail)
The most standard / simplest solution obviously is changing the declaration to the following: var dir,name,ext: shortstring; The other option obviously is to add {$H-} or {$LONGSTRINGS OFF} before the declaration, that effectively does the same.
-- Tomas Hajny,2007 년 11 월 23 일 12:34 오후
(E-mail)
another possable answer is to use {R+} (openstring on) will cause all string passes to be flexable size this seems to help. you can deline a variable as openstring instead of string or shortstring.
-- Allen Harrington,2007 년 11 월 30 일 02:28 오후
(E-mail)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Access Request, Session and Application in Struts2If we want to use request, Session and application in JSP, what should we do? We can obtain Map type objects such as Req...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.