Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Graeme Geldenhuys

On 2017-09-23 21:31, Martok wrote:

the $R directive accepts resource scripts (RC) and compiles the RES file from it
on demand.


Also note that that is only true for Windows. FPC doesn't include a 
resource compiler for any other platforms. So if no resource compiler 
exists, you will get a compilation error until you make other plans. 
Another FPC limitation that really should be resolved.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Sven Barth via fpc-pascal
On 24.09.2017 12:12, Graeme Geldenhuys wrote:
> On 2017-09-23 21:31, Martok wrote:
>> the $R directive accepts resource scripts (RC) and compiles the RES
>> file from it
>> on demand.
> 
> Also note that that is only true for Windows. FPC doesn't include a
> resource compiler for any other platforms. So if no resource compiler
> exists, you will get a compilation error until you make other plans.
> Another FPC limitation that really should be resolved.

You are aware that FPC supports resources on basically all platforms?
After all it was introduced for Lazarus back before 1.0 or so.

Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Sven Barth via fpc-pascal
On 23.09.2017 22:31, Martok wrote:
> Hi all,
> 
> the $R directive accepts resource scripts (RC) and compiles the RES file from 
> it
> on demand.
> 
> However, that only happens if the RES file does not exist - if it does, the
> resource compiler is never invoked. Even clean-building the unit from source
> does not recompile the resource file. This is a bit awkward when the resource
> script (or any of the linked files) is changed: the only way to recreate the
> resource unit appears to be removing both the compiled unit and resource file.
> 
> Is there some sort of flag for this? I'd be fine with just recompiling the
> resource file every time the unit is compiled, windres is fast enough...

Please report a bug.

Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax to select constant or variable with function call

2017-09-24 Thread wkitty42

On 09/24/2017 01:55 AM, Michael Van Canneyt wrote:

Then define
function Find_Color(anArray :PVGA256Array; r ,g ,b : Word) : Byte;
  Var
   Dist,closest:Double;
   i,bestchoice:Byte;

begin
    Closest:=20;
    For i:= 0 to 255 do
   Begin
  Dist :=  ((R-AnArray^[i].R))*((R-AnArray^[i].R))
     + ((G-AnArray^[i].G)*(G-Anarray^[i].G))
     + ((B-AnArray^[i].B)*(B-AnArray^[i].B));
  If Dist


should that be Find_Color:=BestChoice; ??


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Graeme Geldenhuys

On 2017-09-24 13:50, Sven Barth via fpc-pascal wrote:

You are aware that FPC supports resources on basically all platforms?


I know that. What I meant is that FPC only ships with a Windows resource 
compiler - ability to compile RC files to RES files. All other platforms 
you have to find your own Resource Compiler. So on a clean system with a 
fresh FPC install, only under Windows will you have the ability to 
compile source code that references .rc files.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Sven Barth via fpc-pascal
On 24.09.2017 17:15, Graeme Geldenhuys wrote:
> On 2017-09-24 13:50, Sven Barth via fpc-pascal wrote:
>> You are aware that FPC supports resources on basically all platforms?
> 
> I know that. What I meant is that FPC only ships with a Windows resource
> compiler - ability to compile RC files to RES files. All other platforms
> you have to find your own Resource Compiler. So on a clean system with a
> fresh FPC install, only under Windows will you have the ability to
> compile source code that references .rc files.

Because it's only Windows that we provide a setup for. If someone would
provide an FPC implemented resource compiler we'd include it.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Graeme Geldenhuys

On 2017-09-24 16:49, Sven Barth via fpc-pascal wrote:

Because it's only Windows that we provide a setup for.



Huh?  I've been downloading the official FPC console installers for 
FreeBSD and Linux since 6 years ago. I never use distro packages 
managers for FPC.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Giulio Bernardi
I think that what Sven meant is that fpc's Windows installers include binutils,
while this is not true for other platforms: that is, you need to have ld on your
system if you want to use it as a linker, fpc does not provide it.

Same as for windres: if you need it, usually you can install it from mingw's
binutils. In fedora I can install it from mingw32-binutils (or 
mingw64-binutils).
I see that a package with the same name also exists in FreeBSD, so I assume it
will contain windres as well.

https://www.freshports.org/devel/mingw32-binutils/

Giulio

On 24/09/17 16:53, Graeme Geldenhuys wrote:
> On 2017-09-24 16:49, Sven Barth via fpc-pascal wrote:
>> Because it's only Windows that we provide a setup for.
> 
> 
> Huh?  I've been downloading the official FPC console installers for FreeBSD 
> and
> Linux since 6 years ago. I never use distro packages managers for FPC.
> 
> Regards,
>   Graeme
> 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Sven Barth via fpc-pascal
Am 24.09.2017 18:14 schrieb "Giulio Bernardi" :
>
> I think that what Sven meant is that fpc's Windows installers include
binutils,
> while this is not true for other platforms: that is, you need to have ld
on your
> system if you want to use it as a linker, fpc does not provide it.

Exactly.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax to select constant or variable with function call

2017-09-24 Thread James Richters
Thank you for explaining how to achieve this.  
I am curious about the meaning behind the prefixes you used:
>  TVGA256Array = Array[0..255] of VGARGBRec;  
>  PVGA256Array = ^TVGA256Array;
Do the T and P in front of VGA256Array have a special meaning or significance?  
 I see things like that all the time, but never really understood why there are 
these designations.

I should have mentioned that not all my arrays are [0..255], Most are, but I 
have some that are [0..15] and one that is [1..14] Is there a way to implement 
a variable size array and somehow use the array minimum and maximum element in 
the for loop?

> The loop can still be optimized, but that is another topic.

Please elaborate, how this loop could be optimized?  I've been trying to think 
of ways to improve it, and suggestions would be most welcome.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Graeme Geldenhuys

On 2017-09-24 19:02, Sven Barth via fpc-pascal wrote:

system if you want to use it as a linker, fpc does not provide it.

Exactly.


Exactly my point! Why? Why does the official FPC installer for Windows 
give a more workable solution out of the box (1), but official 
installers for other platforms don't?


And please don't tell me the usual "Delphi compatibility" for G*d sake.


1. Ability to compile source code with .RC reference and magically
   compile those to .RES as needed.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax to select constant or variable with function call

2017-09-24 Thread Sven Barth via fpc-pascal
On 24.09.2017 21:07, James Richters wrote:
> Thank you for explaining how to achieve this.  
> I am curious about the meaning behind the prefixes you used:
>>  TVGA256Array = Array[0..255] of VGARGBRec;  
>>  PVGA256Array = ^TVGA256Array;
> Do the T and P in front of VGA256Array have a special meaning or 
> significance?   I see things like that all the time, but never really 
> understood why there are these designations.

"T" and "P" are simply the typical Hungarian notations in Pascal for
ordinary types and pointer types respectively.

> I should have mentioned that not all my arrays are [0..255], Most are, but I 
> have some that are [0..15] and one that is [1..14] Is there a way to 
> implement a variable size array and somehow use the array minimum and maximum 
> element in the for loop?

If you use open array parameters you can do that. E.g.

=== code begin ===

program tdynarr;

const
  Array1: array[0..3] of LongInt = (1, 2, 3, 4);
  Array2: array[2..6] of LongInt = (1, 2, 3, 4, 5);

{ Important: a dynamic array type (aka "TArray = array of LongInt") for
the array parameter will only work with 0 based array constants (in this
case Array1) }
procedure DoArray(aArr: array of LongInt);
begin
  Writeln(Low(aArr), '..', High(aArr));
end;

begin
  DoArray(Array1);
  DoArray(Array2);
end.

=== code end ===

Please note that an open array is always zero based so the output of the
above example will be:

=== output begin ===

0..3
0..4

=== output end ===

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Sven Barth via fpc-pascal
On 24.09.2017 22:55, Graeme Geldenhuys wrote:
> On 2017-09-24 19:02, Sven Barth via fpc-pascal wrote:
>>> system if you want to use it as a linker, fpc does not provide it.
>> Exactly.
> 
> Exactly my point! Why? Why does the official FPC installer for Windows
> give a more workable solution out of the box (1), but official
> installers for other platforms don't?

Because on non-Windows systems (especially the *nix ones) we rely on
their package distributions systems and it's up to the package
maintainers to set up the packages accordingly for their distribution so
that they pull in the required packages. Such a system does not exist on
Windows however so we bundle everything there.

Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax to select constant or variable with function call

2017-09-24 Thread Ralf Quint
On 9/24/2017 12:07 PM, James Richters wrote:
> Thank you for explaining how to achieve this.  
> I am curious about the meaning behind the prefixes you used:
>>  TVGA256Array = Array[0..255] of VGARGBRec;  
>>  PVGA256Array = ^TVGA256Array;
> Do the T and P in front of VGA256Array have a special meaning or 
> significance?   I see things like that all the time, but never really 
> understood why there are these designations.
It is called (IMHO a bad form of) "Hungarian Notation", an identifier
naming convention that should help to make source code more readable. In
[Borland,Turbo,Free]Pascal, the first latter is indicating what kind of
indentifier it is.
 "t" denotes a Type
 "p" denotes a pointer to a Type
"c" denotes a constant
(I personally prefer to use low case letters for that preceding
character, it is IMHO much better readable).

So yes, in this case, the T and P do have a special meaning, but are of
no significance...

Ralf


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Martok
> Also note that that is only true for Windows. FPC doesn't include a 
> resource compiler for any other platforms. So if no resource compiler 
> exists, you will get a compilation error until you make other plans. 
AFAIK, windres is available for lots of other platforms. If you have to install
some package, that shoud not really surprise a developer?
I would assume that FPC just tries to call a resource compiler on all platforms
and fails with some error message if it isn't available?

If so, I wouldn't worry too much about having our own resource compiler. The RC
script language is actually quite complex, and there'd be next to no benefit to
reinventing the wheel.

--
Martok

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Resource compilation

2017-09-24 Thread Martok
Am 24.09.2017 um 14:50 schrieb Sven Barth via fpc-pascal:
> Please report a bug.

Well this is awkward - I tried to provide a test project for the report, and
couldn't get it to *not* work. The real-world project that has this issue for me
has the resource included from a file in a package, and it seems like this is
somehow significant. Might be more of a Lazarus issue then.

There is still a bug in that the RES is not recompiled if the PPU is present but
the RES is not (causes error 9029), but I'll report that separately, after
figuring out what is going on here...

--
Martok

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Syntax to select constant or variable with function call

2017-09-24 Thread Jamesmail

should that be Find_Color:=BestChoice; ??


Yes, it should be, Also noticed a typo in my groupings, it wouldn't  
affect anything but I like to make it clear.


So now I have this for the function:

function Find_Color(Constref ColorArray :TVGA256Array; R ,G ,B : Word) : Byte;
Var
  Dist,Closest:Double;
  I,BestChoice:Byte;
Begin
   Closest:=20;
   For I:= 0 to 255 do
  Begin
 Dist := ((R-ColorArray[i].R)*(R-ColorArray[i].R))
   + ((G-ColorArray[i].G)*(G-ColorArray[i].G))
   + ((B-ColorArray[i].B)*(B-ColorArray[i].B));
 If Dist < Closest Then
Begin
   Closest:=Dist;
   BestChoice:=I;
End;
  End;
   Find_Color:=BestChoice;
end;

I have 2 arrays that are not [0..255],  one is [1..14] the other is  
[0..15] is there a way I could expand this scheme to use those arrays  
as well?   The For loop would need to adjust to the size of the arrays  
somehow.


James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal