[fpc-pascal] Command line FPC/Lazarus SVN downloader/installer

2012-01-10 Thread Reinier Olislagers
Hi Lazarus & FPC people,

I got very tired of writing Windows and Linux batch files, so I've
written an FPC/Lazarus installer that allows you to keep a copy of FPC
and Lazarus that it updates from SVN.
This copy can live apart from a regular FPC/Lazarus install as it uses
--primary-config path for Lazarus.

Currently set to FPC 2.6 fixes, but you can easily change that in the
program code.

(I had earlier worked on extending the LazUpdater program, but that
seemed to be just too much code. Who knows, when finished with all
requirements, my new code will look the same, but we'll see ;) )

Advice and comments gratefully received.

Thanks,
Reinier

Source code: http://lazarus.freepascal.org/index.php/topic,15701.0.html
Already done:
* Program runs on Windows
* Download FPC & Lazarus SVN sources
* Make/compile FPC and Lazarus
* Create fpc.cfg in FPC directory
* Build lazdatadesktop using compiled lazbuild
* Use --primary-config-path for lazbuild compilations, create directory
if it doesn't exit
* Lazarus/FPC SVN URL and install directory can be specified in main unit
* Code workaround for SVN server problems (retry mechanism)
* Check FPC and make are the right kind (not Delphi make or a random
program that happens to be called fpc.exe
* Implement bare metal installer on Windows (download SVN executable,
make/binutils): note: have some issues with binutils...
* Check for existing FPC compiler and download bootstrap compiler
executable from SVN if none present


To do:
* Download/install help, if possible change Lazarus settings so it works
out of the box
* Use (e.g.) ini file for config instead of hardcoded data in the main unit
* User-configurable compiler switches (-gh -gl etc) for both FPC and Lazarus
* Check that crosscompiling x64 code works on Windows
* Linux + OSX versions
* Perhaps a GUI
* Test in general
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 16:41, Sven Barth wrote:

On 10.01.2012 22:02, waldo kitty wrote:

hummm... i may not need this specialization, then... i'm not comparing
the entire record but portions of the fields in the records... i've made
a few changes that should make this easier for me to do... let me show
an example of an input record...


It's not about YOU comparing the entire record. The TFPGList uses that
internally for it's own bookkeeping.


ahhh!


The specialization is mostly for type safety and ease of use. As I show you
below a simple pointer based TList works as well (if you follow some advices).
In the end it should be easier to handle than an array ;)


i never did like pointers... hard to wrap my head around what was what and how 
to access certain things... but then again, i'm self-taught ;)



ISS (Zarya)
1 25544U 98067A 11355.91136867 .00021672 0-0 28116-3 0 6701
2 25544 51.6441 296.4760 0024445 190.7247 276.2995 15.58432251750217


this breaks out like this...

line columns example description
0 1-24 ISS (Zarya) common name

1 1 1 element line number
1 3-7 25545 catalog number
1 8 U elset classification
1 10-17 98067A international designator
1 19-32 11355.91136867 epoch (UTC)
1 34-43 .00021672 1st deriv of mean motion
1 45-52 0-0 2nd deriv of mean motion
1 54-61 28116-3 B* drag term
1 63 0 element set type
1 65-68 670 element number
1 69 1 checksum

2 1 2 element line number
2 3-7 25545 catalog number
2 9-16 51.6441 orbit inclination
2 18-25 296.4760 rt ascension acend node
2 27-33 0024445 eccentricity
2 35-42 190.7247 arg of perigee (degrees)
2 44-51 276.2995 mean anomaly (degrees)
2 53-63 15.58432251 mean motion (revs/day)
2 64-68 75021 rev number at epoch
2 69 3 checksum


so i now have the following to define the record... since i only need
the catalog number to check for duplicates and the epoch to determine
which one to keep, i've added those two fields to the record and pull
them during the reading of the data (see Input_Satellite_List procedure
below)...


Wouldn't it be easier for you to parse the complete two lines into a full blown
record (just asking).


in the future, i will want to do this... however, this tool is a first step into 
mangling^H^H^H^H^H^Hssaging TLE data... the only purpose for this tool is to 
merge TLE files together into one master file with /ALL/ available satellite 
TLEs listed... the current old DOS program simply cannot do this due to memory 
constraints... as such, i only need know the catalog number and the epoch of the 
two... once the final sorted merged list is completed, it is all going to be 
written back to a plain 7bit ascii text file like it all originated from... this 
text file is then used for my other satellite and astronomy related applications ;)



Then you don't need to parse them later on and can just do
a "YourRecord.MeanAnomaly" (for example). Using a TStringList with the correct
parameters can also remove the burden from you to seperate the values by hand.


at this time, this only needs be done with these two (sub)fields in the TLE 
entries... i'm only interested in these two but am storing everything to make it 
easier to later run thru the list or collection or array and write the three 
original lines to a master TLE text file...



Function IsSameReal(num1,num2 : double) : integer;

begin
if (num1 < num2) then IsSameReal := -1
else
if (num1 = num2) then IsSameReal := 0
else
if (num1 > num2) then IsSameReal := 1;
end;


You can shorten this by using the "CompareValue" function from unit "Math":

function IsSameReal(num1,num2: Double): Integer;
begin
IsSameReal := CompareValue(num1, num2);
end;


interesting! in fact, i don't really even need "IsSameReal" as i can simply use 
CompareValue directly with these two numbers?



(though I would name that function CompareReal instead of IsSameReal ;) )


hahaha! true :)


something else i need to make sure of is that this will compile on my
OS/2 FPC 2.4.2 since that is the environment it will be under when it
goes production... unless, of course, there's a shiney new
0s2260full.zip file for me to play with ;)


[...]


as i wrote in another message, my windows' boxen update from SVN and
every time i've tried to update FPC and make whatever, it breaks and i'm
scared to break what i currently have working... i always have to blow
the directory away, then svn it all back down, and then do the make
thing... the ugly part is that i also have lazarus built with and using
this svn'd version of FPC so i definitely do not want to be breaking
that, either...

a second reason is i don't do the svn thing on the OS/2 box and so have
to rely on an install package for that OS... the last time i did this, i
unzipped os2242full.zip to /fpc and went from there... i recall having
to manually configure a lot of stuff, though... include paths and the
like... i still don't have the help working properly in any environment
which greatly hampers things :/


You'll need to ask Tomas Hajny then as he is the one 

Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Tomas Hajny
On 10 Jan 12, at 23:50, Marco van de Voort wrote:
> In our previous episode, Tomas Hajny said:
> > BTW, the supplied HTML docs cannot be used if installing onto FAT 
> > with OS/2 due to the 8.3 restrictions (not that I'd expect you to use 
> > FAT with your OS/2 unless having very good reasons, just for 
> > completeness sake ;-) ).
> 
> We really should switch the IDE to CHM. Basically installation is copying to
> a directory and putting a line in the fp.ini

Well, I just played with using CHMs with FP IDE under OS/2 and 
realized that I get a nice immediate SIGSEGV when using the context 
help with the CHM help files, whereas everything works fine with both 
the standard HTML docs and also the INF files created by Graeme 
(rtl.inf + fcl.inf). :/ It could well be that that this is due to 
some bug in the OS/2 RTL triggered by different RTL functions used in 
the CHM support units (i.e. I don't want to blame the CHM support 
implementation nor its integration to the FP IDE necessarily), but 
that's what I get right now...

Tomas

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Marco van de Voort
In our previous episode, Tomas Hajny said:
> BTW, the supplied HTML docs cannot be used if installing onto FAT 
> with OS/2 due to the 8.3 restrictions (not that I'd expect you to use 
> FAT with your OS/2 unless having very good reasons, just for 
> completeness sake ;-) ).

We really should switch the IDE to CHM. Basically installation is copying to
a directory and putting a line in the fp.ini
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Tomas Hajny
On 10 Jan 12, at 16:02, waldo kitty wrote:
 .
 .
> something else i need to make sure of is that this will compile on my OS/2 
> FPC 
> 2.4.2 since that is the environment it will be under when it goes 
> production... 
> unless, of course, there's a shiney new 0s2260full.zip file for me to play 
> with ;)

...which there is, of course... ;-) (equally to os2244full.zip which 
you apparently skipped for some reason).


> a second reason is i don't do the svn thing on the OS/2 box and so have to 
> rely 
> on an install package for that OS... the last time i did this, i unzipped 
> os2242full.zip to /fpc and went from there... i recall having to manually 
> configure a lot of stuff, though... include paths and the like... i still 
> don't 
> have the help working properly in any environment which greatly hampers 
> things :/

You should consider using the provided installer instead of just 
manually unpacking the file. Not that it updates the paths for you 
(but that shouldn't be necessary if you let the installer to update 
your previous installation in the same directory) but it configures 
the IDE to use the supplied docs at least (note that the creation of 
the help index from the supplied HTML docs takes quite some time 
though).

BTW, the supplied HTML docs cannot be used if installing onto FAT 
with OS/2 due to the 8.3 restrictions (not that I'd expect you to use 
FAT with your OS/2 unless having very good reasons, just for 
completeness sake ;-) ).

Tomas

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Sven Barth

On 10.01.2012 22:02, waldo kitty wrote:

On 1/10/2012 14:41, Sven Barth wrote:

On 10.01.2012 20:12, waldo kitty wrote:

i don't know what this is pointing to because it is evidently not in my
sources but in a unit i'm loading... the actual compiler message is

(750,50) Error: Operator is not overloaded
satsort.pas(434) Fatal: There were 1 errors compiling module, stopping
satsort.pas(0) Fatal: Compilation aborted



Oh damn it, I forgot about that.

Is it possible for you to update to version 2.6? The problem is the
following:
the list I mentioned to you uses a equality operator ("=") of two
values of the
type you specialize with. Thus you need an overloaded operator in case of
records. But you can't use a global overloaded operator (which you
could do in
FPC 2.4.5), as the specialization will only see those types, functions
and
operators that were visible when the generic (the TFPGList) was
declared. So
you'll need to use advanced records for that (which are only available
from
2.6.0 on).


hummm... i may not need this specialization, then... i'm not comparing
the entire record but portions of the fields in the records... i've made
a few changes that should make this easier for me to do... let me show
an example of an input record...


It's not about YOU comparing the entire record. The TFPGList uses that 
internally for it's own bookkeeping.


The specialization is mostly for type safety and ease of use. As I show 
you below a simple pointer based TList works as well (if you follow some 
advices). In the end it should be easier to handle than an array ;)




ISS (Zarya)
1 25544U 98067A 11355.91136867 .00021672 0-0 28116-3 0 6701
2 25544 51.6441 296.4760 0024445 190.7247 276.2995 15.58432251750217


this breaks out like this...

line columns example description
0 1-24 ISS (Zarya) common name

1 1 1 element line number
1 3-7 25545 catalog number
1 8 U elset classification
1 10-17 98067A international designator
1 19-32 11355.91136867 epoch (UTC)
1 34-43 .00021672 1st deriv of mean motion
1 45-52 0-0 2nd deriv of mean motion
1 54-61 28116-3 B* drag term
1 63 0 element set type
1 65-68 670 element number
1 69 1 checksum

2 1 2 element line number
2 3-7 25545 catalog number
2 9-16 51.6441 orbit inclination
2 18-25 296.4760 rt ascension acend node
2 27-33 0024445 eccentricity
2 35-42 190.7247 arg of perigee (degrees)
2 44-51 276.2995 mean anomaly (degrees)
2 53-63 15.58432251 mean motion (revs/day)
2 64-68 75021 rev number at epoch
2 69 3 checksum


so i now have the following to define the record... since i only need
the catalog number to check for duplicates and the epoch to determine
which one to keep, i've added those two fields to the record and pull
them during the reading of the data (see Input_Satellite_List procedure
below)...


Wouldn't it be easier for you to parse the complete two lines into a 
full blown record (just asking). Then you don't need to parse them later 
on and can just do a "YourRecord.MeanAnomaly" (for example). Using a 
TStringList with the correct parameters can also remove the burden from 
you to seperate the values by hand.




Function IsSameReal(num1,num2 : double) : integer;

begin
if (num1 < num2) then IsSameReal := -1
else
if (num1 = num2) then IsSameReal := 0
else
if (num1 > num2) then IsSameReal := 1;
end;


You can shorten this by using the "CompareValue" function from unit "Math":

function IsSameReal(num1,num2: Double): Integer;
begin
  IsSameReal := CompareValue(num1, num2);
end;

(though I would name that function CompareReal instead of IsSameReal ;) )


i'm not sure where the equality operator you speak of above comes from
or why i need it in play :/



It's inside the implementation of TFPGList. I don't remember exactly 
where, but it's used in there.



something else i need to make sure of is that this will compile on my
OS/2 FPC 2.4.2 since that is the environment it will be under when it
goes production... unless, of course, there's a shiney new
0s2260full.zip file for me to play with ;)


[...]


as i wrote in another message, my windows' boxen update from SVN and
every time i've tried to update FPC and make whatever, it breaks and i'm
scared to break what i currently have working... i always have to blow
the directory away, then svn it all back down, and then do the make
thing... the ugly part is that i also have lazarus built with and using
this svn'd version of FPC so i definitely do not want to be breaking
that, either...

a second reason is i don't do the svn thing on the OS/2 box and so have
to rely on an install package for that OS... the last time i did this, i
unzipped os2242full.zip to /fpc and went from there... i recall having
to manually configure a lot of stuff, though... include paths and the
like... i still don't have the help working properly in any environment
which greatly hampers things :/


You'll need to ask Tomas Hajny then as he is the one who is most 
familiar with OS/2. But there seems to indeed be a os2260full.zip at 
Source

Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 14:41, Sven Barth wrote:

On 10.01.2012 20:12, waldo kitty wrote:

i don't know what this is pointing to because it is evidently not in my
sources but in a unit i'm loading... the actual compiler message is

(750,50) Error: Operator is not overloaded
satsort.pas(434) Fatal: There were 1 errors compiling module, stopping
satsort.pas(0) Fatal: Compilation aborted



Oh damn it, I forgot about that.

Is it possible for you to update to version 2.6? The problem is the following:
the list I mentioned to you uses a equality operator ("=") of two values of the
type you specialize with. Thus you need an overloaded operator in case of
records. But you can't use a global overloaded operator (which you could do in
FPC 2.4.5), as the specialization will only see those types, functions and
operators that were visible when the generic (the TFPGList) was declared. So
you'll need to use advanced records for that (which are only available from
2.6.0 on).


hummm... i may not need this specialization, then... i'm not comparing the 
entire record but portions of the fields in the records... i've made a few 
changes that should make this easier for me to do... let me show an example of 
an input record...


ISS (Zarya)
1 25544U 98067A   11355.91136867  .00021672  0-0  28116-3 0  6701
2 25544  51.6441 296.4760 0024445 190.7247 276.2995 15.58432251750217


this breaks out like this...

linecolumns  example  description
  0 1-24 ISS (Zarya)  common name

  1 11element line number
  1 3-7  25545catalog number
  1 8Uelset classification
  1 10-1798067A   international designator
  1 19-3211355.91136867   epoch (UTC)
  1 34-43 .00021672   1st deriv of mean motion
  1 45-52 0-0 2nd deriv of mean motion
  1 54-61 28116-3 B* drag term
  1 63   0element set type
  1 65-68 670 element number
  1 69   1checksum

  2 12element line number
  2 3-7  25545catalog number
  2 9-16  51.6441 orbit inclination
  2 18-25296.4760 rt ascension acend node
  2 27-330024445  eccentricity
  2 35-42190.7247 arg of perigee (degrees)
  2 44-51276.2995 mean anomaly (degrees)
  2 53-6315.58432251  mean motion (revs/day)
  2 64-6875021rev number at epoch
  2 69   3checksum


so i now have the following to define the record... since i only need the 
catalog number to check for duplicates and the epoch to determine which one to 
keep, i've added those two fields to the record and pull them during the reading 
of the data (see Input_Satellite_List procedure below)...


type
  cat_nbr= string[5];
  sat_name   = string[25];
  line_data  = string[69];
  two_line   = array [1..2] of line_data;
  three_line_data = record
  satname : sat_name;
  satdata : two_line;
  catnbr  : cat_nbr;
  epoch   : double;
end;


var
  aList  : TSatDataList;


[...]


Function IsSameReal(num1,num2 : double) : integer;

begin
  if (num1 < num2) then IsSameReal := -1
  else
if (num1 = num2) then IsSameReal := 0
else
  if (num1 > num2) then IsSameReal := 1;
end;

Function IsSameStr(str1,str2 : cat_nbr) : boolean;

begin
  IsSameStr := str1 = str2;
end;

Procedure Input_Satellite_List(var aInputFile: TextFile);

var
  data : three_line_data;
  dupe : boolean;
  i,x  : integer;

begin
  if not EOF(aInputFile) then
begin
  Readln(aInputFile,data.satname);
  Readln(aInputFile,data.satdata[1]);
  Readln(aInputFile,data.satdata[2]);
  data.catnbr := Copy(data.satdata[1],3,5);
  data.epoch  := Real_Value(data.satdata[1],19,14);
  dupe := False;
  for i := 0 to aList.Count -1 do
if IsSameStr(aList[i].catnbr,data.catnbr) then  // make the dupe check
  begin// if catnbrs are the same
dupe := True;  // first mark dupe true
x := IsSameReal(aList[i].epoch,data.epoch); // compare epochs
case x of
 -1: begin // aList < data, replace with data
   aList[i] := data;
 end;
 0 : begin // aList = data, ignore data
 end;
 1 : begin // aList > data, ignore data
 end;
end; {case}
  end; {if IsSameStr}
  if not dupe then
aList.Add(data);   // not a dupe so add it
end; {if not EOF}
end; {Procedure Input Satellite List}


with this not working like this i just need to shove them into a list or 
collection or something to hold them for more processing and

Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Marco van de Voort
In our previous episode, Tomas Hajny said:
> >> TSortedCollection (as provided in unit objects).
> >
> > The classes unit also has a TCollection, which can be sorted on any field
> > of
> > the collection items ?
> 
> When looking at it, using or descending Classes.TCollection for simple
> data records seemed to be considerably more complex than with
> Objects.TSortedCollection (I studied our documentation and also searched
> on WWW for general Delphi examples). I even found an implementation of the
> TP/BP TSortedCollection for the Delphi model on the Web (based on Delphi
> classes) which kind of suggested that the original TP/BP objects could
> provide some additional value (by saving some effort necessary otherwise).
> Admittedly, it might easily be due to lack of my knowledge, but these were
> my results.

IIRC the problem with TP collections was that the forall operator used
hackery to call a nested procedure.  With proper ISO procedure variable
support in 2.6.0 that could be done good :-)

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 13:13, Sven Barth wrote:

On 10.01.2012 18:15, waldo kitty wrote:

On 1/10/2012 05:39, Sven Barth wrote:


// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.


thank you very much! it has definitely given me some ideas... one thing
that concerns me, though, is that i'm using FPC 2.4.5 console mode...
this fgl unit is available in this FPC for this line?

> type
> TSatDataList = specialize TFPGList;


Yes, this feature is available in 2.4.5 (though I would nevertheless suggest to
you to update to the newly released 2.6.0 :) )


yes, i've got to figure out how to do that... my windows' installations are 
pulled from SVN following the procedure on one of the wiki pages but i have a 
.bat file that is scripted for this process... the only problem is that i 
generally have to start clean if i want to update fpc because something goes 
wrong during the make but i don't recall what... i do something almost exactly 
the same with lazarus (from the same page) but i manually compile it from within 
lazarus instead of trying from the command line... i'm rather scared to mess up 
what is currently a working installation :/



the other thing i'm trying to figure out is if i can easily and speedily
pull portions of the satdata fields for the sort and duplicate
functions... i'm thinking that it would be faster to expand the record
into each of its actual fields and fill them during import... i think
i'd rather copy(x,y,z) to individual record field during import rather
than pulling the needed fields during the sorting and merging phases...


Yes, that might indeed be faster or better.


i implemented it by adding two additional fields to the record and filling that 
data as above... then i use those two fields in the dupe finding and comparison 
flow... i don't know if it works due to an error i just wrote about in another 
message in this thread... i'm hoping you or someone else has an idea where to 
look as i'm completely lost :(



You could also try to experiment with TFPGMap if your satellite data has a
unique key. You specialize it like the following:

type
TYourMap = specialize TFPGMap;

Where YourKeyType is the type of your key (e.g. String, Integer, etc) and
YourKeyData is your data record. For more info I'd advice you to take a look at
the class itself and its parent class TFPSMap, because I haven't used that class
yet.


i think i'll leave that alone for now ;)


and one more trip through the raft of data can adjust the social name
for the satellite :)



Can't you adjust that when reading the data as well?


yes but it is still a loop of several hundred or thousand comparisons for each 
item in the list... i've not updated the XRF (crossreference) files in almost a 
year and there have been a lot of new birds launched... the XRF files currently 
number 37 files (of up to 1000 entries each) containing 15194 entries in 
total... not all satellites are represented because their common names are fine 
(by my standards) or they are not flying any more... the only thing this list is 
really for is to fix up the common names to what i want to use... for example 
satellite 04321 has two common names... AO-05 and Australis-OSCAR-5... amateur 
radio folk likely prefer AO-05 whereas myself and others prefer the OSCAR 
notation... it makes it easier for grouping tasks since not all OSCAR units are 
the same for the first characters... AO-06 is AMSAT-OSCAR-6 so you can see that 
the 'A' means different things... there's all kinds of common names, too... 
debris for certain ones (hundreds of entries for the chinese satellite that was 
destroyed) with a more informative name, rocket body parts, despin weights, 
shields, numerous covers, etc... [/rambling talk]



i'm trying to figure out how to also work out a method of deleting TLEs
of birds who are down... another list to process and walk through :P


Are they listed in another file?


they probably will be... the XRF files have two leading spaces (i didn't design 
the format) and i could probably hijack the first space to put an 'X' if the 
satellite is no longer flying... then i could use you suggestion below to 
eliminate those entries from the list...



If so then I suggest the following: read the file and for each record read you
search in the list for that satellite and do a "YourList.Delete(Index)" where
"Index" is your for-loop's counter variable (if a satellite is contained more
than once in your list I'd suggest you to use a downwards counting loop from
"YourList.Count - 1 downto 0" otherwise you'll get "List index out of
bounds"-exceptions if you access the last elements (depending on how many you
deleted). Otherwise you can cancel the loop using "Break" again.


i'll try to remember this and will likely do this during the common name 
adjustment phase... another field in the record for flying or not and then skip 
those not flying during the output file writing ;)

__

Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Sven Barth

On 10.01.2012 20:12, waldo kitty wrote:

On 1/10/2012 05:39, Sven Barth wrote:

// -1 if aLeft < aRight
// 0 if aLeft = aRight
// 1 if aLeft > aRight
begin
// compare the two items and return the correct value
end;

// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.


i've been working with what you sent and have run into a problem i don't
understand or how to find and fix...

Error: Operator is not overloaded
You’re trying to use an overloaded operator when it is not overloaded
for this type.


i don't know what this is pointing to because it is evidently not in my
sources but in a unit i'm loading... the actual compiler message is

(750,50) Error: Operator is not overloaded
satsort.pas(434) Fatal: There were 1 errors compiling module, stopping
satsort.pas(0) Fatal: Compilation aborted



Oh damn it, I forgot about that.

Is it possible for you to update to version 2.6? The problem is the 
following: the list I mentioned to you uses a equality operator ("=") of 
two values of the type you specialize with. Thus you need an overloaded 
operator in case of records. But you can't use a global overloaded 
operator (which you could do in FPC 2.4.5), as the specialization will 
only see those types, functions and operators that were visible when the 
generic (the TFPGList) was declared. So you'll need to use advanced 
records for that (which are only available from 2.6.0 on).


Here is what you would do if you'd use 2.6.0:

// at the top of your unit/program:
{$mode objfpc} // or whatever mode you use
{$modeswitch advancedrecords} // you don't need this in mode Delphi only

// the declaration of your record (for sake of an example I'll reuse 
your three_line_data record)


type
  three_line_data = record
  satname : sat_name;
  satdata : two_line;
  // now comes the important part
  class operator = (aLeft, aRight: three_line_data) 
Result: Boolean; // You need the "Result" only if you're not using mode 
Delphi or ObjFPC

end;

// later in your program file or in the implementation section of your unit:

class operator three_line_data.= (aLeft, aRight: three_line_data) 
Result: Boolean;

begin
  Result := aLeft.satname = aRight.satname; // I don't know whether 
this is your real comparison for equality, but it's just an example

end;

Now you should be able to successfully specialize the TFPGList.

If you can't update to 2.6.0:
1. I'd like to know why :)
2. You can then use the TList which is based on pointers (and requires a 
bit manual housekeeping, but I can help you here as well if you want)



i don't know if this is because i wrote an IsSameStr function because i
could not find an IsSame one... i actually have two... one checks if two
string vars have the same string and the other checks if two double vars
have the same double... IsSameStr is boolean for true or false but
IsSameReal returns an integer of -1 (var1 < var2), 0 (var1 = var2) or 1
(var1 > var2)...


The IsSame was merely a placeholder for a function that compares your 
two satellites records (and that you already seem to have created ;) )


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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 05:39, Sven Barth wrote:

// -1 if aLeft < aRight
// 0 if aLeft = aRight
// 1 if aLeft > aRight
begin
// compare the two items and return the correct value
end;

// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.


i've been working with what you sent and have run into a problem i don't 
understand or how to find and fix...


Error: Operator is not overloaded
You’re trying to use an overloaded operator when it is not overloaded for 
this type.



i don't know what this is pointing to because it is evidently not in my sources 
but in a unit i'm loading... the actual compiler message is


(750,50) Error: Operator is not overloaded
satsort.pas(434) Fatal: There were 1 errors compiling module, stopping
satsort.pas(0) Fatal: Compilation aborted

i don't know if this is because i wrote an IsSameStr function because i could 
not find an IsSame one... i actually have two... one checks if two string vars 
have the same string and the other checks if two double vars have the same 
double... IsSameStr is boolean for true or false but IsSameReal returns an 
integer of -1 (var1 < var2), 0 (var1 = var2) or 1 (var1 > var2)...


am i in the right target area?

i should mention my fpc version is

╔═[■]  About  ═╗
║║
║   FreePascal IDE for Win32 for i386║
║Target CPU: i386║
║   Version 1.0.12 2011/06/01║
║(Compiler Version 2.4.5)║
║║
║   Copyright (C) 1998-2009 by   ║
║║
║  Bérczi Gábor  ║
║ Pierre Muller  ║
║  and   ║
║  Peter Vreman  ║
║   OK   ▄   ║
║▀ ║
╚╝
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get path to current theme icons on linux?

2012-01-10 Thread Daniel Gaspary
On Mon, Jan 9, 2012 at 18:45, Krzysztof  wrote:
> I need to load icon associated by file extension. On windows I done
> this by WinAPI function ExtractAssociatedIcon(). On linux is not so
> easy, because we have GNOME, KDE, XFCE, LXDE etc, but I noticed that
> icons are stored in this same place

I believe that file/dir locations are ruled by freedesktop
specifications.I have found this:

http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#s2_layout
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Sven Barth

On 10.01.2012 18:15, waldo kitty wrote:

On 1/10/2012 05:39, Sven Barth wrote:


// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.


thank you very much! it has definitely given me some ideas... one thing
that concerns me, though, is that i'm using FPC 2.4.5 console mode...
this fgl unit is available in this FPC for this line?

 > type
 > TSatDataList = specialize TFPGList;


Yes, this feature is available in 2.4.5 (though I would nevertheless 
suggest to you to update to the newly released 2.6.0 :) )





the other thing i'm trying to figure out is if i can easily and speedily
pull portions of the satdata fields for the sort and duplicate
functions... i'm thinking that it would be faster to expand the record
into each of its actual fields and fill them during import... i think
i'd rather copy(x,y,z) to individual record field during import rather
than pulling the needed fields during the sorting and merging phases...


Yes, that might indeed be faster or better.

You could also try to experiment with TFPGMap if your satellite data has 
a unique key. You specialize it like the following:


type
  TYourMap = specialize TFPGMap;

Where YourKeyType is the type of your key (e.g. String, Integer, etc) 
and YourKeyData is your data record. For more info I'd advice you to 
take a look at the class itself and its parent class TFPSMap, because I 
haven't used that class yet.




and one more trip through the raft of data can adjust the social name
for the satellite :)



Can't you adjust that when reading the data as well?


i'm trying to figure out how to also work out a method of deleting TLEs
of birds who are down... another list to process and walk through :P


Are they listed in another file?
If so then I suggest the following: read the file and for each record 
read you search in the list for that satellite and do a 
"YourList.Delete(Index)" where "Index" is your for-loop's counter 
variable (if a satellite is contained more than once in your list I'd 
suggest you to use a downwards counting loop from "YourList.Count - 1 
downto 0" otherwise you'll get "List index out of bounds"-exceptions if 
you access the last elements (depending on how many you deleted). 
Otherwise you can cancel the loop using "Break" again.




thanks again for the info!


You're welcome. That's what we're here for ;)

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 03:38, Tomas Hajny wrote:

On Tue, January 10, 2012 05:14, waldo kitty wrote:

uncle has been failing me for the last several hours and i'm loosing sight
of
what i'm trying to get done... i've seen references to using a
tstringlinst as
well as something apparently non-existent called a tarray... in all of the
stuff
i've seen on tstringlinst, there's nothing that i find that is close to
what i'm
(thinking i'm) looking for... and here's where i keep getting diverted
away from
the final goal due to trying to follow everything else :/


I've tried something similar recently. After trying to figure out how to
use the classes included with FPC and build something on top of them, I
resorted to using the old TP/BP compatible object model with
TSortedCollection (as provided in unit objects).


yes, i believe i have some hard (l)earned TP code with that... i just hunted it 
up and it appears that i built my own objects with TSortedCollection... i've got 
to try to go back over it and see if i can figure it out... it does a lot of 
digging message bases to assemble linkage paths for the messages' distribution...


i'm also going to take a look at what sven barth has offered... i might be able 
to knock this out in another few hours IF i can use the specialize thing he 
pointed me to...


thanks to both you and he for your responses ;)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread waldo kitty

On 1/10/2012 05:39, Sven Barth wrote:


// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.


thank you very much! it has definitely given me some ideas... one thing that 
concerns me, though, is that i'm using FPC 2.4.5 console mode... this fgl unit 
is available in this FPC for this line?


> type
> TSatDataList = specialize TFPGList;


the other thing i'm trying to figure out is if i can easily and speedily pull 
portions of the satdata fields for the sort and duplicate functions... i'm 
thinking that it would be faster to expand the record into each of its actual 
fields and fill them during import... i think i'd rather copy(x,y,z) to 
individual record field during import rather than pulling the needed fields 
during the sorting and merging phases...


and one more trip through the raft of data can adjust the social name for the 
satellite :)


i'm trying to figure out how to also work out a method of deleting TLEs of birds 
who are down... another list to process and walk through :P


thanks again for the info!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Sven Barth

Am 10.01.2012 05:14, schrieb waldo kitty:

my problem is that i cannot find any similar examples where an array of
records is built, sorted and duplicates are eliminated based on specific
factors of the two records being compared...

uncle has been failing me for the last several hours and i'm loosing
sight of what i'm trying to get done... i've seen references to using a
tstringlinst as well as something apparently non-existent called a
tarray... in all of the stuff i've seen on tstringlinst, there's nothing
that i find that is close to what i'm (thinking i'm) looking for... and
here's where i keep getting diverted away from the final goal due to
trying to follow everything else :/


My suggestion is to use a generic list from unit fgl.

Following example:

type
  TSatDataList = specialize TFPGList;

In the following I assume that you know how to use classes, if not feel 
free to ask back ;)


When now reading the file you do the following (based on your code):

Procedure Input_Satellite(aInputFile: TextFile; aList: TSatDataList);
  var
data: three_line_data;
  begin
  if not EOF(aInputFile) then
begin
Readln(aInputFile,data.satname);
Readln(aInputFile,data.satdata[1]);
Readln(aInputFile,data.satdata[2]);
aList.Add(data);
end; {if}
  end; {Procedure Input_Satellite}

For checking whether a element in the list is the same as another one 
you can do the following (assuming the new item is called "data"):


duplicate := False;
for i := 0 to aList.Count - 1 do
  if IsSame(aList[i], data) then begin // I don't know how exactly your 
check looks like, so I just put a placeholder here :)

// correct the old data instead of inserting
aList[i].{...}
duplicate := True;
Break; // if you're sure that there is no more dupliacate in the 
list you can break here

  end;

if not dupliate then
  aList.Add(data); // no duplicate found so add the new element

For sorting the list you need to define a compare function:

function SatDataCompare(aLeft, aRight: three_line_data): Integer;
// aLeft and aRight are of the same type with which you specialized the 
TFPGList

// returns
// -1 if aLeft < aRight
// 0 if aLeft = aRight
// 1 if aLeft > aRight
begin
  // compare the two items and return the correct value
end;

// somewhere else:
aList.Sort(@SatDataCompare);

What I wrote here might not be perfect, but it should give you a start.

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Tomas Hajny
On Tue, January 10, 2012 10:09, michael.vancann...@wisa.be wrote:
> On Tue, 10 Jan 2012, Tomas Hajny wrote:
>> On Tue, January 10, 2012 05:14, waldo kitty wrote:
>>
>>
>> Hi,
>>
>> .
>> .
>>> are certain enforced limits on these lines... as such, i have defined a
>>> record
>>>
>>> type
>>>sat_name   = string[25];
>>>line_data  = string[69];
>>>two_line   = array [1..2] of line_data;
>>>three_line_data = record
>>>satname : sat_name;
>>>satdata : two_line;
>>>  end;
>>>
>>> const
>>>max_sats = 65536;
>>>
>>> var
>>>sat_data : array [1..max_sats] of three_line_data;
>>>abuf : two_line;
>>>new_data : three_line_data;
>>>
>>> right now i'm loading the array via a simple readln into the array
>>> elements...
>>>
>>> Procedure Input_Satellite(index : word);
>>>begin
>>>if not EOF(fsat) then
>>>  begin
>>>  Readln(fsat,sat_data[index].satname);
>>>  Readln(fsat,sat_data[index].satdata[1]);
>>>  Readln(fsat,sat_data[index].satdata[2]);
>>>  end; {if}
>>>end; {Procedure Input_Satellite}
>>>
>>> this is fine for the initial loading but i'm needing to read additional
>>> TLE
>>> files and insert those records into the above array... my problem is
>>> that
>>> i need
>>> the array sorted on a sectional value from sat_data[index].satdata[1]
>>>
>>>sat_catnr:= Copy(abuf[1],3,5);
>>> and
>>>new_catnr:= Copy(abuf[1],3,5);
>>>
>>> which are loaded and compared between sat_data[index].sat_data and
>>> new_data.sat_data
>>>
>>> in the case of collisions (same catnr), i need to choose between the
>>> greater of
>>> a pair of values from the stored record (sat_data) and the new record
>>> (new_data)
>>> read from a file...
>>>
>>> Function Real_Value(buffer : string;
>>>start,length : integer) : double;
>>>var
>>>  result : integer;
>>>  answer : double;
>>>begin
>>>buffer := Copy(buffer,start,length);
>>>Convert_Blanks(buffer);
>>>if buffer = '' then
>>>  buffer := '0';
>>>Val(buffer,answer,result);
>>>if result = 0 then
>>>  Real_Value := answer
>>>else
>>>  Real_Value := 0.0;
>>>end; {Function Real_Value}
>>>
>>>
>>> via...
>>>
>>>sat_epoch:= Real_Value(abuf[1],19,14);
>>> and
>>>new_epoch:= Real_Value(abuf[1],19,14);
>>>
>>>
>>> which are loaded and compared between sat_data[index].satdata and
>>> new_data.satdata...
>>>
>>> my problem is that i cannot find any similar examples where an array of
>>> records
>>> is built, sorted and duplicates are eliminated based on specific
>>> factors
>>> of the
>>> two records being compared...
>>>
>>> uncle has been failing me for the last several hours and i'm loosing
>>> sight
>>> of
>>> what i'm trying to get done... i've seen references to using a
>>> tstringlinst as
>>> well as something apparently non-existent called a tarray... in all of
>>> the
>>> stuff
>>> i've seen on tstringlinst, there's nothing that i find that is close to
>>> what i'm
>>> (thinking i'm) looking for... and here's where i keep getting diverted
>>> away from
>>> the final goal due to trying to follow everything else :/
>>
>> I've tried something similar recently. After trying to figure out how to
>> use the classes included with FPC and build something on top of them, I
>> resorted to using the old TP/BP compatible object model with
>> TSortedCollection (as provided in unit objects).
>
> The classes unit also has a TCollection, which can be sorted on any field
> of
> the collection items ?

When looking at it, using or descending Classes.TCollection for simple
data records seemed to be considerably more complex than with
Objects.TSortedCollection (I studied our documentation and also searched
on WWW for general Delphi examples). I even found an implementation of the
TP/BP TSortedCollection for the Delphi model on the Web (based on Delphi
classes) which kind of suggested that the original TP/BP objects could
provide some additional value (by saving some effort necessary otherwise).
Admittedly, it might easily be due to lack of my knowledge, but these were
my results.

Tomas


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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread michael . vancanneyt



On Tue, 10 Jan 2012, Tomas Hajny wrote:


On Tue, January 10, 2012 05:14, waldo kitty wrote:


Hi,

.
.

are certain enforced limits on these lines... as such, i have defined a
record

type
   sat_name   = string[25];
   line_data  = string[69];
   two_line   = array [1..2] of line_data;
   three_line_data = record
   satname : sat_name;
   satdata : two_line;
 end;

const
   max_sats = 65536;

var
   sat_data : array [1..max_sats] of three_line_data;
   abuf : two_line;
   new_data : three_line_data;

right now i'm loading the array via a simple readln into the array
elements...

Procedure Input_Satellite(index : word);
   begin
   if not EOF(fsat) then
 begin
 Readln(fsat,sat_data[index].satname);
 Readln(fsat,sat_data[index].satdata[1]);
 Readln(fsat,sat_data[index].satdata[2]);
 end; {if}
   end; {Procedure Input_Satellite}

this is fine for the initial loading but i'm needing to read additional
TLE
files and insert those records into the above array... my problem is that
i need
the array sorted on a sectional value from sat_data[index].satdata[1]

   sat_catnr:= Copy(abuf[1],3,5);
and
   new_catnr:= Copy(abuf[1],3,5);

which are loaded and compared between sat_data[index].sat_data and
new_data.sat_data

in the case of collisions (same catnr), i need to choose between the
greater of
a pair of values from the stored record (sat_data) and the new record
(new_data)
read from a file...

Function Real_Value(buffer : string;
   start,length : integer) : double;
   var
 result : integer;
 answer : double;
   begin
   buffer := Copy(buffer,start,length);
   Convert_Blanks(buffer);
   if buffer = '' then
 buffer := '0';
   Val(buffer,answer,result);
   if result = 0 then
 Real_Value := answer
   else
 Real_Value := 0.0;
   end; {Function Real_Value}


via...

   sat_epoch:= Real_Value(abuf[1],19,14);
and
   new_epoch:= Real_Value(abuf[1],19,14);


which are loaded and compared between sat_data[index].satdata and
new_data.satdata...

my problem is that i cannot find any similar examples where an array of
records
is built, sorted and duplicates are eliminated based on specific factors
of the
two records being compared...

uncle has been failing me for the last several hours and i'm loosing sight
of
what i'm trying to get done... i've seen references to using a
tstringlinst as
well as something apparently non-existent called a tarray... in all of the
stuff
i've seen on tstringlinst, there's nothing that i find that is close to
what i'm
(thinking i'm) looking for... and here's where i keep getting diverted
away from
the final goal due to trying to follow everything else :/


I've tried something similar recently. After trying to figure out how to
use the classes included with FPC and build something on top of them, I
resorted to using the old TP/BP compatible object model with
TSortedCollection (as provided in unit objects).


The classes unit also has a TCollection, which can be sorted on any field of
the collection items ?

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


Re: [fpc-pascal] sorting and merging array of records

2012-01-10 Thread Tomas Hajny
On Tue, January 10, 2012 05:14, waldo kitty wrote:


Hi,

 .
 .
> are certain enforced limits on these lines... as such, i have defined a
> record
>
> type
>sat_name   = string[25];
>line_data  = string[69];
>two_line   = array [1..2] of line_data;
>three_line_data = record
>satname : sat_name;
>satdata : two_line;
>  end;
>
> const
>max_sats = 65536;
>
> var
>sat_data : array [1..max_sats] of three_line_data;
>abuf : two_line;
>new_data : three_line_data;
>
> right now i'm loading the array via a simple readln into the array
> elements...
>
> Procedure Input_Satellite(index : word);
>begin
>if not EOF(fsat) then
>  begin
>  Readln(fsat,sat_data[index].satname);
>  Readln(fsat,sat_data[index].satdata[1]);
>  Readln(fsat,sat_data[index].satdata[2]);
>  end; {if}
>end; {Procedure Input_Satellite}
>
> this is fine for the initial loading but i'm needing to read additional
> TLE
> files and insert those records into the above array... my problem is that
> i need
> the array sorted on a sectional value from sat_data[index].satdata[1]
>
>sat_catnr:= Copy(abuf[1],3,5);
> and
>new_catnr:= Copy(abuf[1],3,5);
>
> which are loaded and compared between sat_data[index].sat_data and
> new_data.sat_data
>
> in the case of collisions (same catnr), i need to choose between the
> greater of
> a pair of values from the stored record (sat_data) and the new record
> (new_data)
> read from a file...
>
> Function Real_Value(buffer : string;
>start,length : integer) : double;
>var
>  result : integer;
>  answer : double;
>begin
>buffer := Copy(buffer,start,length);
>Convert_Blanks(buffer);
>if buffer = '' then
>  buffer := '0';
>Val(buffer,answer,result);
>if result = 0 then
>  Real_Value := answer
>else
>  Real_Value := 0.0;
>end; {Function Real_Value}
>
>
> via...
>
>sat_epoch:= Real_Value(abuf[1],19,14);
> and
>new_epoch:= Real_Value(abuf[1],19,14);
>
>
> which are loaded and compared between sat_data[index].satdata and
> new_data.satdata...
>
> my problem is that i cannot find any similar examples where an array of
> records
> is built, sorted and duplicates are eliminated based on specific factors
> of the
> two records being compared...
>
> uncle has been failing me for the last several hours and i'm loosing sight
> of
> what i'm trying to get done... i've seen references to using a
> tstringlinst as
> well as something apparently non-existent called a tarray... in all of the
> stuff
> i've seen on tstringlinst, there's nothing that i find that is close to
> what i'm
> (thinking i'm) looking for... and here's where i keep getting diverted
> away from
> the final goal due to trying to follow everything else :/

I've tried something similar recently. After trying to figure out how to
use the classes included with FPC and build something on top of them, I
resorted to using the old TP/BP compatible object model with
TSortedCollection (as provided in unit objects).

Tomas


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