Hello.
I'm trying to use such a code:
type TVar = object param1, param2:string; .... end;
TVarList = object Items:array of TVar; count:cardinal; ..... end;
In Delphi and FPC it works fine, but in GPC i get an error
45: warning: missing string capacity -- assuming 255 49: error: syntax error before `of'
Is it possible to use dynamic arrays in gpc? I had searched gpc manual, but it is not clear for me - may be, it is possible to use dynamic array only as function parametr? It seems to be a little strange - dynamic arrays are a very old feature :(
-- Best regards, Yuriy Ohonin.
On 05 Feb 2008, at 05:43, Ohonin Yuriy wrote:
I had searched gpc manual, but it is not clear for me - may be, it is possible to use dynamic array only as function parametr? It seems to be a little strange - dynamic arrays are a very old feature :(
You are confusing open arrays and dynamic arrays. Open arrays are an established feature, dynamic arrays are a Delphi invention. See e.g. this page for an explanation of the difference: http://rvelthuis.de/articles/articles-openarr.html
Jonas
Ohonin Yuriy wrote:
Hello.
I'm trying to use such a code:
type TVar = object param1, param2:string; .... end;
TVarList = object Items:array of TVar; count:cardinal; ..... end;
In Delphi and FPC it works fine, but in GPC i get an error
45: warning: missing string capacity -- assuming 255 49: error: syntax error before `of'
Is it possible to use dynamic arrays in gpc?
See section [6.2.11.5 EP’s Schema Types including ‘String’] of the gpc manual.
ISO 10206 Extended Pascal feature.
type RealArray (n: Integer) = array [1 .. n] of Real; Matrix (n, m: PositiveInteger) = array [1 .. n, 1 .. m] of Integer;
The type ‘RealArray’ in this example is called a Schema with the discriminant ‘n’. To declare a variable of such a type, write:
var Foo: RealArray (42);
Regards,
Adriaan van Os
On Tuesday 05 February 2008 17:13, you wrote:
Ohonin Yuriy wrote:
Hello.
I'm trying to use such a code:
type TVar = object param1, param2:string; .... end;
TVarList = object Items:array of TVar; count:cardinal; ..... end;
In Delphi and FPC it works fine, but in GPC i get an error
49: error: syntax error before `of'
Is it possible to use dynamic arrays in gpc?
See section [6.2.11.5 EP’s Schema Types including ‘String’] of the gpc manual.
ISO 10206 Extended Pascal feature.
type RealArray (n: Integer) = array [1 .. n] of Real; Matrix (n, m: PositiveInteger) = array [1 .. n, 1 .. m] of Integer;
The type ‘RealArray’ in this example is called a Schema with the discriminant ‘n’. To declare a variable of such a type, write:
var Foo: RealArray (42);
Regards,
Adriaan van Os
Thank you, but will i be able to change array length during runtime in this case? Hear is my goals: I need a list of objects. I need to add a new object to this list at run time. (this could be slow) I need quik access to any object. So it will be no good to use pointers like
type PListElement = ^TListElement; TListElement = object ... next, previos:PListElement; ... end;
Also, what about
45: warning: missing string capacity -- assuming 255
On Thursday 07 February 2008 00:47, Russell Whitaker wrote:
On Wed, 6 Feb 2008, Ohonin Yuriy wrote:
[...]
Also, what about
45: warning: missing string capacity -- assuming 255
Use a type. Examples:
type string80 = string( 80 ); alongstring = string( 100000 );
Russ
The main advandage of Pascal is that strong typization mekes working whith pointers and dynamic structures very easy. If i need to write my own class for Normal Strings, and for most of functions to work whith it - it is better switch to fpc, or just c++ - it's already written.
Farewell.
Ohonin Yuriy wrote:
The main advandage of Pascal is that strong typization mekes working whith pointers and dynamic structures very easy. If i need to write my own class for Normal Strings, and for most of functions to work whith it - it is better switch to fpc, or just c++ - it's already written.
Well, currently gpc support trurly dynamic strings (and arrays) only via pointers, like:
type StrPtrT = ^String;
function blanks(n : integer) : StrPtrT; var result : StrPtrT; i : integer; begin new(result, n); for i := 1 to n do result[i] := ' '; blanks := result; end;
You may look at the 'stringschemademo.pas' demo program to see some possibilites offered by gpc strings.