Re: [fpc-pascal] TProcess.CommandLine > 255 fails
On 04 Jan 2009, at 02:34, T.Guilleminot wrote: > 2.2.x or 2.3.x? I used the 2.2.0 (provided by Ubuntu repositories). Then I just upgraded and tested in 2.2.2-8 but problem is still the same :( Please provide a compilable program that demonstrates the problem. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with c header conversion
each "union" is a separate case for pascal. another thing is that the structure is quite agly and does not reveale the logicals usage. The problem is that pascal does not allow you to use multiple cases in single record, that would require you to declare additional types. _PFColorSize = record case Integer of 0: (dwRGBBitCount : DWORD); 1: (dwYUVBitCount : DWORD); 2: (dwAlphaBitDepth : DWORD); end; _PFColorMask = record case Integer of 0: ( dwRBitMask : DWORD; dwGBitMask : DWORD; dwBBitMask : DWORD; dwRGBAAlphaBitMask: DWORD; ); 1: (dwYBitMask : DWORD; dwUBitMask : DWORD; dwVBitMask : DWORD ); end; PDDPixelFormat = ^TDDPixelFormat; _DDPIXELFORMAT = record dwSize: DWORD; dwFlags: DWORD; dwFourCC: DWORD; _size : PFColorSize; _mask : PFColorMask; end; DDPIXELFORMAT = _DDPIXELFORMAT; TDDPixelFormat = _DDPIXELFORMAT; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] property of an array
On Sun, 04 Jan 2009 05:25:40 -0500, Joost van der Sluis wrote: Op zaterdag 03-01-2009 om 19:04 uur [tijdzone -0500], schreef Jeremy Cowgar: myObj.ColumnNames := [ 'Id', 'Name', 'Age' ]; Error: Ordinal expression expected A list of values between square brackets are a set, not an array. You'll have to do: AnArray[0] := 'Id'; anArray[1] := 'Name'; anArray[2] := 'Age'; myObj.ColumnNames := AnArray; Or create a constant array and use that. My original definition is: procedure SetColumnNames(names : StringArray); property ColumnNames : StringArray write SetColumnNames; Why does it work when I call it by the procedure? myObj.SetColumnNames(['Id', 'Name', 'Age']); but not: myObj.ColumnNames := ['Id', 'Name', 'Age']; Jeremy ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TProcess.CommandLine > 255 fails
procedure Run_Command_Wait(TheCommand : string); cdecl; This 'string' is of the type shortstring, and thus will truncate your string to 255 characters. Change it in ansistring or add {$H+} to the beginning of your program. I would advice to declare "TheCommand : AnsiString" instead of changing the compiler switch because then it's independend from such changes/settings. Especially, when such switches change other things too and one day you may need some of these other things and get the side effect of changing the string type too. In general I would advice not to use the generic types "string" (nor "integer") at all. It only leads to confusion because noone knows (or is aware) of what type is meant in particular. Why not use the strings that is needed? Jürgen Hestermann. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Debugger support for FP (issues with libgdb.a)
Joost van der Sluis wrote: > Op maandag 22-12-2008 om 23:17 uur [tijdzone +], schreef Andrea: >> Joost van der Sluis wrote: >>> Op zondag 21-12-2008 om 17:29 uur [tijdzone +], schreef Andrea: >>> >> Apparently it cannot work due to some incompatibility with gdb-6.8 > > There is a reason I said that the linker may not find the wrong libgdb.a > files. > >> http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=12636 >> >> will try again in the future. > > Or download the right libgdb-version from the link I gave you, place it > in the right directory, remove any other libgdb.a etc. files and try > again. > > Thereafter it will work with your newer version of gdb. > > Or did you do this and did it still not work? My gdb is version 6.8, on your link I can only find 6.2.1 Will that be a problem when it runs? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Debugger support for FP (issues with libgdb.a)
Jonas Maebe wrote: > > On 04 Jan 2009, at 16:51, Andrea wrote: > >> My gdb is version 6.8, on your link I can only find 6.2.1 >> Will that be a problem when it runs? > > No: libgdb.a basically contains a complete gdb implementation in that > library, and the IDE will use that. It's not an interface to your > system-installed gdb > Now I understand. > Maybe: that older gdb (6.2.1) may not fully support your system. > will try and let you know Andrea ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] property of an array
Op zaterdag 03-01-2009 om 19:04 uur [tijdzone -0500], schreef Jeremy Cowgar: > myObj.ColumnNames := [ 'Id', 'Name', 'Age' ]; > Error: Ordinal expression expected A list of values between square brackets are a set, not an array. You'll have to do: AnArray[0] := 'Id'; anArray[1] := 'Name'; anArray[2] := 'Age'; myObj.ColumnNames := AnArray; Or create a constant array and use that. Joost. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TProcess.CommandLine > 255 fails
Thanks ! Changing "TheCommand" to ansistring seems work ! Did not think about this simple thing. I'm testing more deeply. Thanks again. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TProcess.CommandLine > 255 fails
Please provide a compilable program that demonstrates the problem. Jonas Create a myini.ini file containing : [TEST] CMD_OK=echo 'Hello !' CMD_NOT_OK=mencoder dvb://M6 -sws 9 -of lavf -lavfopts format=mp4 -vf scale=480:320,dsize=480:320,harddup -ovc x264 -x264encopts bitrate=500:vbv_maxrate=1500:vbv_bufsize=2000:nocabac:me=umh:trellis=1:level_idc=30:global_header:threads=2:pass=1:turbo -oac faac -faacopts mpeg=4:object=2:br=160:raw -channels 2 -srate 48000 -o test.mp4 Then the program : program Pb_TProcess_255; uses Process, inifiles; var Ini_File : TIniFile; CMD_OK, CMD_NOT_OK : ansistring; // Read INI File Procedure Read_Parameters_File; begin Ini_File := TIniFile.Create('./myini.ini'); with Ini_File do begin CMD_OK:=ReadString('TEST', 'CMD_OK', 'error'); CMD_NOT_OK:=ReadString('TEST', 'CMD_NOT_OK', 'error'); writeln; writeln(' CMD_OK : '+CMD_OK); writeln; writeln(' CMD_NOT_OK : '+CMD_NOT_OK); writeln; end; end; // Run an OS Command and *Wait* his Completion to Continue procedure Run_Command_Wait(TheCommand : string); cdecl; var AProcess: TProcess; Begin AProcess := TProcess.Create(nil); AProcess.CommandLine := TheCommand; AProcess.Options := AProcess.Options+ [poWaitOnExit]; AProcess.Execute; AProcess.Free; end; // Main Program begin Read_Parameters_File; Run_Command_Wait(CMD_OK); writeln; Run_Command_Wait(CMD_NOT_OK); end. The first command runs OK but the 2nd one reports an error and shows the 255th character : Hello ! MEncoder 2:1.0~rc2-0ubuntu17 (C) 2000-2007 MPlayer Team CPU: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz (Family: 6, Model: 15, Stepping: 6) CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. -faaco is not an MEncoder option Exiting... (error parsing command line) THanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Problem with c header conversion
Hello, I'm trying to convert c header code from "Windows Mobile API 5" to pascal and I'm getting wrong size of converted record: original c header: typedef struct _DDPIXELFORMAT { DWORD dwSize; DWORD dwFlags; DWORD dwFourCC; union { DWORD dwRGBBitCount; DWORD dwYUVBitCount; DWORD dwAlphaBitDepth; }; union { DWORD dwRBitMask; DWORD dwYBitMask; }; union { DWORD dwGBitMask; DWORD dwUBitMask; }; union { DWORD dwBBitMask; DWORD dwVBitMask; }; union { DWORD dwRGBAlphaBitMask; }; } DDPIXELFORMAT, * LPDDPIXELFORMAT; and my pascal conversion: PDDPixelFormat = ^TDDPixelFormat; _DDPIXELFORMAT = record dwSize: DWORD; dwFlags: DWORD; dwFourCC: DWORD; case Integer of 0: ( dwRGBBitCount : DWORD; dwYUVBitCount : DWORD; dwAlphaBitDepth : DWORD; ); 1: ( dwRBitMask : DWORD; dwYBitMask : DWORD; ); 2: ( dwGBitMask : DWORD; dwUBitMask : DWORD; ); 3: ( dwBBitMask : DWORD; dwVBitMask : DWORD; ); 4: ( dwRGBAlphaBitMask: DWORD; ); end; DDPIXELFORMAT = _DDPIXELFORMAT; TDDPixelFormat = _DDPIXELFORMAT; embedded visual c++ 4 returns sizeof(_DDPIXELFORMAT) = 32 free pascal 2.2.2 arm/wince target returns sizeof(_DDPIXELFORMAT) = 24 When I retrive these structure from Windows, field dwSize = 32 Where is problem? Maybe I shuld use special compiler directive or switch? Michal p.s. sorry for my bad english ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Debugger support for FP (issues with libgdb.a)
On 04 Jan 2009, at 16:51, Andrea wrote: My gdb is version 6.8, on your link I can only find 6.2.1 Will that be a problem when it runs? No: libgdb.a basically contains a complete gdb implementation in that library, and the IDE will use that. It's not an interface to your system-installed gdb Maybe: that older gdb (6.2.1) may not fully support your system. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TProcess.CommandLine > 255 fails
In our previous episode, Jonas Maebe said: > > > 2.2.x or 2.3.x? > > > > I used the 2.2.0 (provided by Ubuntu repositories). > > Then I just upgraded and tested in 2.2.2-8 but problem is still the > > same :( > > Please provide a compilable program that demonstrates the problem. (Jonas: I asked because I saw a newstr() in that code) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Debugger support for FP (issues with libgdb.a)
Op zondag 04-01-2009 om 15:51 uur [tijdzone +], schreef Andrea: > Joost van der Sluis wrote: > > Op maandag 22-12-2008 om 23:17 uur [tijdzone +], schreef Andrea: > >> Joost van der Sluis wrote: > >>> Op zondag 21-12-2008 om 17:29 uur [tijdzone +], schreef Andrea: > >>> > >> Apparently it cannot work due to some incompatibility with gdb-6.8 > > > > There is a reason I said that the linker may not find the wrong libgdb.a > > files. > > > >> http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=12636 > >> > >> will try again in the future. > > > > Or download the right libgdb-version from the link I gave you, place it > > in the right directory, remove any other libgdb.a etc. files and try > > again. > > > > Thereafter it will work with your newer version of gdb. > > > > Or did you do this and did it still not work? > > My gdb is version 6.8, on your link I can only find 6.2.1 > Will that be a problem when it runs? No Joost ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TProcess.CommandLine > 255 fails
Op zondag 04-01-2009 om 12:31 uur [tijdzone +0100], schreef T.Guilleminot: > procedure Run_Command_Wait(TheCommand : string); cdecl; This 'string' is of the type shortstring, and thus will truncate your string to 255 characters. Change it in ansistring or add {$H+} to the beginning of your program. Joost. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with c header conversion
On 03 Jan 2009, at 12:54, gabor wrote: I'm trying to convert c header code from "Windows Mobile API 5" to pascal and I'm getting wrong size of converted record: original c header: typedef struct _DDPIXELFORMAT { DWORDdwSize; DWORDdwFlags; DWORDdwFourCC; union { DWORD dwRGBBitCount; DWORD dwYUVBitCount; DWORD dwAlphaBitDepth; }; union { DWORD dwRBitMask; DWORD dwYBitMask; }; [snip] and my pascal conversion: "union" in C means that the fields inside this union{..} block all start at the same address, but whatever comes after the union{} block follows all of those fields. Your translation does exactly the inverse: it makes all union blocks start at the same address, but puts the fields inside the union blocks after each other. I don't think you can create sequential unnamed variant parts in Pascal records like the above C struct though, but you can get the same layout and usage by doing this: PDDPixelFormat = ^TDDPixelFormat; _DDPIXELFORMAT = record dwSize: DWORD; dwFlags: DWORD; dwFourCC: DWORD; case Integer of 0: ( dwRGBBitCount : DWORD; ); 1: ( dwYUVBitCount : DWORD; ); 2: ( dwAlphaBitDepth : DWORD; case Integer of 0: ( dwRBitMask : DWORD; ); 1: ( dwYBitMask : DWORD; case Integer of 0: ( dwGBitMask : DWORD; ); 1: ( dwUBitMask : DWORD; case Integer of 0: ( dwBBitMask : DWORD; ); 1: ( dwVBitMask : DWORD; case Integer of 0: ( dwRGBAlphaBitMask: DWORD; ); ); ); ); ); end; In this case it's easy because in each union every field has the same size. If that weren't the case, you would have to put the nested variant parts after the largest field of each variant. Or you could put the variant parts in separate record types and then declare fields of these types (which is cleaner, but then when accessing the fields you will have to add the record field names). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] property of an array
1) type StringArray : array of String; defines a StringArray type to be dynamic array. are you sure, that you have SetColumnNames defined as procedure SetColumnNames(names : StringArray); rather than: procedure SetColumnNames(names : array of string); ??? because if you have procedure SetColumnNames(names : StringArray); you cannot pass array in the following way SetColumnNames(['1','2','3']); because: ['1','2','3'] is an open array, while SetColumnNames requires a dynamic array to be passed. btw, there's no way to define open-array type. Open arrays can be passed only as a parameters. 2) if you have dynamic array type declared you CAN use it as a property type StringArray : array of String; ... fNames : StringArray; procedure SetColumnNames(ANames: StringArray); property ColumnNames : StringArray read fNames write SetColumnNames .. So if you want to assign a value to the ColumnNames property, you can do it, only by generating a dynamic array first: // the function generates a StringArray from Open String Array! function MakeStringArray(const Strs: array of string): StringArray; var i : integer; begin SetLength(Result, length(strs)); for i := 0 to length(strs) - 1 do Result[i] := strs[i]; end; ... // compiles and works nicely and effectevely // glory to FreePascal (and originally delphi 7 introducing open arrays) myobj.Names := MakeStringArray(['1','2','3','4','5']); 3) You must understand the difference between dynamic array types and open-arrays parameters ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] property of an array
dmitry boyarintsev wrote: 1) type StringArray : array of String; defines a StringArray type to be dynamic array. are you sure, that you have SetColumnNames defined as procedure SetColumnNames(names : StringArray); rather than: procedure SetColumnNames(names : array of string); ??? Hm, you are right. When I was able to do SetColumnNames([...]); was before I changed to a defined type, trying to get around this problem. Jeremy ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Writing a compiler
I just finished taking compiler techniques class this semester and I'd like to write my own based on the one used in the class. The class uses Java with JLex and JavaCUP, but I don't really like Java and I want to rewrite it in FP. However, there are some choices for writing the scanner and parser: 1. PLex & PYacc Question: Differences between 4.1a and FP distributed version? Pros: Easier to translate from original version Cons: Not so easy to translate from EBNF notation 2. Coco/R Question: TP vs Delphi version, which one is more appropriate for FP? Pros: Very close to EBNF, Modula-2 / Oberon-like structure, has many features Cons: Needs changes from original version (my lecturer doesn't give EBNF notation) 3. Handwritten Question: Need some references other than Jack Crenshaw's book Pros: Easier to maintain (someone said, but no prove) Cons: I don't have any practical background on this >From the given choices, which one will you suggest? -- View this message in context: http://www.nabble.com/Writing-a-compiler-tp21285931p21285931.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal