Re: [fpc-pascal] Chaining method calls

2020-03-24 Thread Ryan Joseph via fpc-pascal
Free Pascal - General mailing list wrote > Is it possible to achieve this dynamically without resorting to type > casting? It feels like classes should have a builtin type for each class, > like TClassType, which similar to TObject.ClassType but is a compile time > type. I didn't think enough befo

Re: [fpc-pascal] Chaining method calls

2020-03-24 Thread Michal Wallace via fpc-pascal
Hi Ryan, It's possible. Just change your declaration of `c`: var c: TBase; It still prints TMyClass at the end. Of course, you're only going to have access to methods that are declared in TBase. You can also approach this sort of thing with interfaces... -Michal ( http://tangentstorm.com/ )

Re: [fpc-pascal] Chaining method calls

2020-03-24 Thread Ryan Joseph via fpc-pascal
> On Mar 24, 2020, at 8:39 PM, Michal Wallace via fpc-pascal > wrote: > > Hi Ryan, > > It's possible. Just change your declaration of `c`: > > var c: TBase; > > It still prints TMyClass at the end. > > Of course, you're only going to have access to methods that are declared in > TBase. >

Re: [fpc-pascal] Disable Warning: (6060) Case statement does not handle all possible cases

2020-03-24 Thread fredvs via fpc-pascal
Hello. According to: https://wiki.freepascal.org/Turn_warnings_and_hints_on_or_off > Control specific warnings: > Add > {$warn off} > just after the unit name. So doing this: > unit myunit; > {$warn 6060 off} Still gives some "Warning: (6060) Case statement does not handle all pos

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread wkitty42
On 3/23/20 8:08 PM, fredvs via fpc-pascal wrote: const foldhiddenbit = 7; foldhiddenmask = 1 shl foldhiddenbit; currentfoldhiddenbit = 6; currentfoldhiddenmask = 1 shl currentfoldhiddenbit; foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask)); >Here the warning I

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Alexander Grotewohl
Yes, those constants are defaulting to integer, which can represent both negative and positive values. When you do your shl you're inadvertently causing them to go into the range that pascal thinks is negative. The typed constant should fix it. -- Alexander Grotewohl https://dcclost.com ___

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
Hello WKitty. foldhiddenmask : byte = 1 shl foldhiddenbit; currentfoldhiddenmask : byte = 1 shl currentfoldhiddenbit; foldlevelmask : byte = not (foldhiddenmask or currentfoldhiddenmask); = msedatalist.pas(897,47) Error: (3203) Illegal expression msedatalist.pas(899,61) Error: (32

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Alexander Grotewohl
just to be clear.. you did do foldhiddenbit: byte = 7, etc? -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of fredvs via fpc-pascal Sent: Tuesday, March 24, 2020 12:22:10 PM To: fpc-pascal@lists.freepascal.org Cc: fredvs Subject: Re: [f

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
Hello Alexander. I did: const foldhiddenbit : byte = 7; // line 896 foldhiddenmask : byte = 1 shl foldhiddenbit; // line 897 currentfoldhiddenbit : byte = 6; // line 898 currentfoldhiddenmask : byte = 1 shl currentfoldhiddenbit; // line 899 foldlevelmask : byte = not (foldhiddenmas

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
And only changing this: > foldhiddenbit: byte = 7; Gives also a error message on next line unchanged: > foldhiddenmask = 1 shl foldhiddenbit; // raise a error on that line. Error: (3203) Illegal expression Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabbl

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
And doing this: foldhiddenbit = byte(7); foldhiddenmask = byte(1 shl foldhiddenbit); currentfoldhiddenbit = byte(6); currentfoldhiddenmask = byte(1 shl currentfoldhiddenbit); foldlevelmask = abs(byte(not (foldhiddenmask or currentfoldhiddenmask))); // line 891 Gives also a warning: msedatali

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
This make the compiler happy: foldlevelmask = byte(abs(not (foldhiddenmask or currentfoldhiddenmask))); Not sure it is better to do abs() but so no more warning. Let's fix with it? - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ __

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Bart via fpc-pascal
On Tue, Mar 24, 2020 at 6:00 PM fredvs via fpc-pascal wrote: > OK, I stop. This works? {$mode objfpc} {$apptype console} const foldhiddenbit = byte(7); foldhiddenmask = byte(1 shl foldhiddenbit); currentfoldhiddenbit = byte(6); currentfoldhiddenmask = byte(1 shl currentfoldhiddenbit);

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread wkitty42
On 3/24/20 12:40 PM, fredvs via fpc-pascal wrote: Hello Alexander. I did: const foldhiddenbit : byte = 7; // line 896 foldhiddenmask : byte = 1 shl foldhiddenbit; // line 897 currentfoldhiddenbit : byte = 6; // line 898 currentfoldhiddenmask : byte = 1 shl currentfoldhiddenbit;

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
> what mode are you compiling with? {$mode objfpc}{$h+} - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/list

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Alexander Grotewohl
perhaps calculate those results by hand and assign them.. then fix it later? hehe -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of fredvs via fpc-pascal Sent: Tuesday, March 24, 2020 1:53:19 PM To: fpc-pascal@lists.freepascal.org Cc: f

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
> perhaps calculate those results by hand and assign them.. then fix it later? hehe Yes, that is the thing with the gurus, it must seem complicated. I agree that writing this: > foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask)); is much more impressive than writing this: > f

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Gerhard Scholz
what about foldlevelmask = (not (foldhiddenmask or currentfoldhiddenmask)) and $ff ; instead of the " f... := byte(...) " line ? - Original Message - From: "fredvs via fpc-pascal" To: Cc: "fredvs" Sent: Tuesday, March 24, 2020 1:08 AM Subject: [fpc-pascal] Range check error warn

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
> what about > foldlevelmask = (not (foldhiddenmask or currentfoldhiddenmask)) and $ff ; Ha, this one fpc 3.3.1 like it! No more warning nor error. May I ask you what "and $ff" does, is it the same as "abs()" or keep it the negative value? Many thanks. Fre;D - Many thanks ;-) -- Sent

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Gerhard Scholz
z := x AND y is a bitwise AND (not (foldhiddenmask or currentfoldhiddenmask)) results in dec: -193hex: ff3f bin: 0011 this AND hex: $ff (bin: 1 ) gives bin: 0011 AND bin:

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread fredvs via fpc-pascal
Many thanks Gerhald. Now I have to deeply study your code, I did not catch all at first glance. Write you later. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@list

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Sven Barth via fpc-pascal
schrieb am Di., 24. März 2020, 18:37: > On 3/24/20 12:40 PM, fredvs via fpc-pascal wrote: > > Hello Alexander. > > > > I did: > > > > const > > foldhiddenbit : byte = 7; // line 896 > > foldhiddenmask : byte = 1 shl foldhiddenbit; // line 897 > > currentfoldhiddenbit : byte = 6; // li

Re: [fpc-pascal] Range check error warning.

2020-03-24 Thread Sven Barth via fpc-pascal
Am 24.03.2020 um 01:08 schrieb fredvs via fpc-pascal: Hello. With fpc 3.3.1 there is this warning: "Warning: (4110) Range check error while evaluating constants (-193 must be between 0 and 255)" Here the code pointed by the warning: const foldhiddenbit = 7; foldhiddenmask = 1 shl foldhidd