Re: [fpc-pascal] Problem compiling

2012-08-06 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: > > > > Free Pascal Compiler version 2.7.1 [2012/05/22] for i386 > > > > Anyone have > > an idea what could be wrong? > > Building development versions of FPC always has been and always will be > guaranteed to work only if you start with the latest *r

Re: [fpc-pascal] Problem compiling

2012-08-06 Thread Nico Erfurth
On 05.08.12 23:46, dhkblas...@zeelandnet.nl wrote: > I get: > > text.inc(199,34) Error: Illegal type conversion: "Text" to "TextRec" > > after updating the compiler sources from SVN. > > Free Pascal Compiler version 2.7.1 [2012/05/22] for i386 > > Anyone have an idea what could be wrong? You

[fpc-pascal] printing each Friday the 13 using Pascal

2012-08-06 Thread ik
Hi list, A friend of mine started a hobby project: Printing every Friday the 13, in a range of 5 years . I lack of the time for doing it at the moment, and I wish to add to his github

[fpc-pascal] Re: printing each Friday the 13 using Pascal

2012-08-06 Thread leledumbo
Converting one of the answers there... uses SysUtils; const StartingYear = 2012; var Year,Month: Byte; Date: TDateTime; begin for Year in [0 .. 5] do begin for Month in [1 .. 12] do begin Date := EncodeDate(Year,Month,13); if DayOfWeek(Date) = 5 then begin WriteLn

[fpc-pascal] Re: printing each Friday the 13 using Pascal

2012-08-06 Thread leledumbo
Sorry, missing one thing: Date := EncodeDate(StartingYear + Year,Month,13); -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/printing-each-Friday-the-13-using-Pascal-tp5710496p5710498.html Sent from the Free Pascal - General mailing list archive at Nabble.com.

Re: [fpc-pascal] printing each Friday the 13 using Pascal

2012-08-06 Thread Gerhard Scholz
a quick and dirty solution - Original Message - From: ik To: FPC-Pascal users discussions Sent: Monday, August 06, 2012 1:19 PM Subject: [fpc-pascal] printing each Friday the 13 using Pascal Hi list, A friend of mine started a hobby project: Printing every Friday the 13, in a range of

Re: [fpc-pascal] Re: printing each Friday the 13 using Pascal

2012-08-06 Thread Howard Page-Clark
On 06/8/12 1:32, leledumbo wrote: Minor amendment needed to leledumbo's code to give Friday, and a five year range: uses SysUtils; const startYr: word = 2012; var dt: TDateTime; year, month: word; begin for year in [0..4] do for month in [1..12] do begin dt := EncodeDate(

[fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. ___ fpc-pascal maillist - fpc-pascal@lists.fre

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Howard Page-Clark
On 06/8/12 3:26, Rainer Stratmann wrote: procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. if by address you mean line number, then use t

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 15:26, Rainer Stratmann wrote: procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design time? at design t

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 18:43:04 schrieb Martin: > > How to get all caller adresses of p1 in a program before p1 is executed? > > > > For example p1 is called from 20 different places in a program. > > Then I need the 20 caller adresses. > > At run time, or design time? At runtime. I ment the (me

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Sven Barth
On 06.08.2012 19:28, Rainer Stratmann wrote: Am Monday 06 August 2012 18:43:04 schrieb Martin: How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design ti

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 19:34:23 schrieb Sven Barth: > > You know that scanning the binary code for calls is platform dependant? Yes. [calling opcode] [calleradress] calling opcode can differ and the byteorder of the adress can differ. > So you'd need to write that code for every CPU you want to

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Sven Barth
On 06.08.2012 19:56, Rainer Stratmann wrote: Am Monday 06 August 2012 19:34:23 schrieb Sven Barth: You know that scanning the binary code for calls is platform dependant? Yes. [calling opcode] [calleradress] calling opcode can differ and the byteorder of the adress can differ. The problem h

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 18:28, Rainer Stratmann wrote: Am Monday 06 August 2012 18:43:04 schrieb Martin: How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design tim

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 20:12:41 schrieb Sven Barth: > The problem here is the following: > > Let's suppose the opcode for calling a function on x86 CPUs is 0xCA11. > Now you scan through the code looking for 0xCA11 followed by 4 bit. Byte :-) > The > problem now is that without knowing the cont

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 20:15:53 schrieb Martin: > > You can probably reuse sone code from the system unit. > > below is a copy of dump_stack from fpc. It gets all the addresses > > > {$ifdef FPC_HAS_FEATURE_CONSOLEIO} > Procedure dump_stack(var f : text;bp : Pointer); > var >i : Longint; >

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 21:18:20 schrieb Rainer Stratmann: > Am Monday 06 August 2012 20:15:53 schrieb Martin: > > I do not understand this ... > What is the content of the stack? > Which file 'f'? > Is it read from or write to file 'f'? Ok write to file 'f'. :-) But I still do not understand. __

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Jonas Maebe
On 06 Aug 2012, at 21:06, Rainer Stratmann wrote: > Am Monday 06 August 2012 20:12:41 schrieb Sven Barth: >> The >> problem now is that without knowing the context of a found location >> 0xCA11 you don't know whether it is really a call opcode or some >> immediate data that was passed to some pr

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 21:26:24 schrieb Jonas Maebe: > It doesn't work like that. Regular calls use relative offsets on most (if > not all) architectures we support. And in some cases we generate > position-independent code, so then you'll have look at GOT entries to > figure out the address. The

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Sven Barth
On 06.08.2012 21:48, Rainer Stratmann wrote: Out of curiosity: why don't you use resourcestrings? It seems that is has not the flexibility and simplicity (in its entirety) that I want. I would not call your method "simple" It may is in the beginning more difficult to implement, but if it run

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 20:18, Rainer Stratmann wrote: I do not understand this ... What is the content of the stack? Which file 'f'? Is it read from or write to file 'f'? f is just the STDOUT or logfile where the list of addresses is written to. You would likely use an array instead... But let me sa

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Marco van de Voort
In our previous episode, Sven Barth said: > > The function returns the right language. > > Somehow this sounds like the GNU GetText function _() works. With the > exception that the text which has to be translated is simply searched by > looking through the source code for _("some text")... Not

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Aleksa Todorovic
On Mon, Aug 6, 2012 at 9:48 PM, Rainer Stratmann wrote: > Am Monday 06 August 2012 21:26:24 schrieb Jonas Maebe: >> It doesn't work like that. Regular calls use relative offsets on most (if >> not all) architectures we support. And in some cases we generate >> position-independent code, so then yo

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:17:11 schrieb Martin: > But let me say: I am with everyone else. Using stack/caller info is the > wrong(est) way. I fully agree. > And if you need to ask "What is the content of the stack?" Then you > should not use it. > All this functions are very low level. Usinc this

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 21:39, Rainer Stratmann wrote Can you explain it more? I want not search through the sourcecode, because it makes it less easy. How does an address like $040012a help you find the source? All I need is all caller adresses of p1 in the program. Or an incremented counter at compile

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:37:08 schrieb Aleksa Todorovic: > program test_str_36; > > uses > sysutils; > > function s(str: pchar): pchar; > var > str2: pchar; > begin > if str[0] = '~' then > begin > // string is not localized > str2 := strnew('numero'); // localized version >

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 21:57, Martin wrote: I am still trying to understand what exactly you try to archive. Ok, I read one of the other posts: Do you need to ensure to handle each snippet only once? Are *ALL* snippets constants? either const t1 = 'abc'; or foo('text') and NEVER result of - a

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:57:42 schrieb Martin: > On 06/08/2012 21:39, Rainer Stratmann wrote > > > Can you explain it more? > > I want not search through the sourcecode, because it makes it less easy. > > How does an address like $040012a help you find the source? If I have a list with all call

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 23:36:10 schrieb Martin: > On 06/08/2012 21:57, Martin wrote: > > I am still trying to understand what exactly you try to archive. > > Ok, I read one of the other posts: Do you need to ensure to handle each > snippet only once? > > > Are *ALL* snippets constants? yes, but t

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Sven Barth
On 06.08.2012 22:22, Marco van de Voort wrote: In our previous episode, Sven Barth said: The function returns the right language. Somehow this sounds like the GNU GetText function _() works. With the exception that the text which has to be translated is simply searched by looking through the s

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Martin
On 06/08/2012 22:46, Rainer Stratmann wrote: If the are: use the address of the first char in the snippet ? But then I do not have a list of all caller adresses of s() which I try to get. I still do not understand what is so special about the caller address? Furthermore, you said yourself, y

Re: [fpc-pascal] Get all caller adresses of a procedure/function

2012-08-06 Thread Mark Morgan Lloyd
Rainer Stratmann wrote: All I need is all caller adresses of p1 in the program. You might be able to do that sort of thing by running the program with a profiler and analyzing all captured stacks. But it would be a vast amount of effort, and unless you could guarantee 100% coverage (i.e. fe

[fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
Hi, is it possible to have a virtual class variable? I want to have a pointer available per class that can be a different value. Something like this: TA = class class var Foo: TObject; virtual; end; TB = class(TA) class var Foo: TSpecialObject; override; end; I have in mind

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
My current idea for a solution is here: http://pastebin.com/P3JsDQ03 Can anyone think of something with less code? I guess I could save a little if I skip the property and directly use GetVMT and SetVMT. Regards, Andrew ___ fpc-pascal maillist - fpc

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Paul Ishenin
07.08.12, 8:18, Andrew Haines wrote: Hi, is it possible to have a virtual class variable? I want to have a pointer available per class that can be a different value. Something like this: TA = class class var Foo: TObject; virtual; end; TB = class(TA) class var Foo: TSpecialOb

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
On 08/06/12 23:02, Paul Ishenin wrote: > > Class variable is stored the same way as a regular variable and has the > only difference is that it can be accessible with the class name prefix. > The thing you need requires different implementation - something like > storing a virtual class variable

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Paul Ishenin
07.08.12, 11:24, Andrew Haines wrote: What is the current implementation? I would guess that class vars are stored in the vmt already... No, class var and regular variable has no difference except the scope. It is a static variable which is shared between all instances and descendants - so w

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
Ahhh ok I understand now. , Thank you. -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Paul Ishenin wrote: 07.08.12, 11:24, Andrew Haines wrote: > What is the current implementation? > > I would guess that class vars are stored in the vmt already... No, class var and reg