[fpc-pascal] Re: [Lazarus] Finished full JVM Android application
On Mon, 26 Dec 2011, Sven Barth wrote: Hello together! Today I've finished my first JVM Android application. This could as well be the first (or at least one of the first) complete JVM Android app written in Pascal at all! A nice christmas present for the whole FPC team, thank you :-) Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: How to create this union ?
Better redefining my problem: I have a first union. But on records we do not end case with end. and beneath the union, I have to place another union, or another fields that is not part of the union. How can I do that ? Thanks, Ido On Mon, Dec 26, 2011 at 16:41, ik ido...@gmail.com wrote: Hello, I'm trying to translate the following to Pascal: struct xt_option_call { const char *arg, *ext_name; const struct xt_option_entry *entry; void *data; unsigned int xflags; bool invert; uint8_t nvals; union { uint8_t u8, u8_range[2], syslog_level, protocol; uint16_t u16, u16_range[2], port, port_range[2]; uint32_t u32, u32_range[2]; uint64_t u64, u64_range[2]; double dbl; struct { union nf_inet_addr haddr, hmask; uint8_t hlen; }; struct { uint8_t tos_value, tos_mask; }; struct { uint32_t mark, mask; }; uint8_t ethermac[6]; } val; /* Wished for a world where the ones below were gone: */ union { struct xt_entry_match **match; struct xt_entry_target **target; }; void *xt_entry; void *udata; }; -- h2pas does not capable of translating it, and I'm not sure that I know to make the case statement that will be equivalent for this complex union. How can I translate it ? Thanks, Ido ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to create this union ?
Chelper also has hard-timer converting the structure: It failed on union nf_inet_addr haddr, hmask; so I had to comment it out. Some structures are missing completely. type TAuxType0 = packed record case Integer of 0:(u8 : uint8_t;u8_range : array [0..1] of uint8_t;syslog_level : uint8_t;protocol : uint8_t;); 1:(u16 : uint16_t;u16_range : array [0..1] of uint16_t;port : uint16_t;port_range : array [0..1] of uint16_t;); 2:(u32 : uint32_t;u32_range : array [0..1] of uint32_t;); 3:(u64 : uint64_t;u64_range : array [0..1] of uint64_t;); 4:(dbl : double;); 5:(); //union nf_inet_addr haddr, hmask; 6:(); 7:(); 8:(ethermac : array [0..5] of uint8_t;); end; xt_option_call = packed record arg : Pchar_; ext_name : Pchar_; entry : Pxt_option_entry; data : Pointer; xflags : unsigned int; invert : bool; nvals : uint8_t; val : TAuxType0; (* Wished for a world where the ones below were gone: *) xt_entry : Pointer; udata : Pointer; end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Map of values to array of records
On 26.12.2011 12:50, Howard Page-Clark wrote: On 25/12/11 10:07, Jiří Pavlovský wrote: What do you mean ? I mean the code below works ok, so I don't undestand why it doesn't compile when I use similar construct inside a function. const ranges: array [1..2] of TMyRec = ( (Start:0;Stop:3), (Start:4;Stop:7) ); Are you looking for something like this? (BTW your code snippets are too short to really understand what you can't do). Yes, sorry I should have been more clear. It was late evening and I got frustrated... I now got what I need working. Still if there is a way to make it more concise, Please let me know. {$mode objfpc} uses fgl; type TMyRec = record Start, Stop : integer; End; MyIntType = byte; TArrayType = array of TMyRec; TSubMyMap = specialize TFPGMapChar, TArrayType; TMyMap = specialize TFPGMapChar,TSubMyMap; var t : TMyMap; r : TMyRec; myArray : TArrayType; begin r.Start := 1; r.Stop := 2; SetLength(myArray, 1); myArray[0] := r; t:= TMyMap.Create; t['a'] := TSubMyMap.Create; t['a']['b'] := myArray; writeln(t['a']['b'][0].Start); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Forward declarations
On 11-12-23 07:31 AM, leledumbo wrote: Back to high school time, I use it for turn based battle system for a game. I have two mutually (tail-)recursive procedures where one is the player movement decision (full with prompts) while the other is the enemy's (some AI calculation takes the decision). The battle could start ambushed (enemy first) or preemptive strike (player first). Because of this, the first procedure to call could be either of the two, and because both are mutually recursive, one needs to be declared forward. Thanks! This is a bit more complex than I want for an example in my book, but you've twigged my imagination, and I can use this idea for an example that I can use. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal