Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-27 Thread Lukasz Sokol
On 26/06/17 23:28, Bo Berglund wrote:
[...]
> 
> NEXT:
> It looks like I will have to rewrite my relaying program now used in
> Windows for the conversion to TCP from RS232 to also work as the
> replacement for ser2net on RPi3. This way I can monitor the data
> better and check time intervals etc.
> 
> My problem here is the fact that the RPi is headless so the GUI
> program I have written with Lazarus will not work. Instead I have to
> make a console version that can run on RPi for the test and here I
> have the concern that I am using Application.Processmessages, which I
> believe cannot be used in a console program.
> How can I replace it?
> 
> 

If you are comfortable  with thread programming, you could
have a thread handle the hardware / serial handling 
(by keeping the 'messages' in a 'queue' or 'queues' (one outbound, one inbound).
The serial handling thread would poll the serial port and handle serial sending 
timing etc,
and put the received data into the rx 'queue'. Depending on how fast the serial 
communications
are, the thread could then ThreadSwitch to give up the reminder of its time 
slice if not needed,
and sleep for the rest of the time.

Then your main program would periodically check the queues and depending on 
whether it needs
to do something or not, will do it and then  threadswitch() and sleep(), 

The main thread would then be responsible for network / hi level 'protocol' 
communication,
data conversion 
(e.g. you could assume network data 'text' encoded in base64, or even text 
based json,
that is then converted to/from binary form for serial)

IIRC some network handling components/libraries use threads of their own.

If you wanted to use 'just' network sockets, you'd probably need to handle
network 'low level' communications in threads anyway.

hope this makes (some) sense
_l.

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

Re: [fpc-pascal] FPC 64bit for windows

2017-05-19 Thread Lukasz Sokol
On 19/05/17 16:15, Sven Barth via fpc-pascal wrote:
> Am 19.05.2017 14:53 schrieb "Lukasz Sokol"
> <el.es...@gmail.com
> <mailto:el.es...@gmail.com>>:
>> 
>> On 19/05/17 13:33, Sven Barth via fpc-pascal wrote:
>> 
>>>>> You don't have to build a 32-bit FPC because an official 
>>>>> released installer exists. So this is no problem at all. But 
>>>>> seeing as pretty much everything is moving (or already has
>>>>> moved) to 64-bit, why bother with 32-bit these days.
>>>>> [referring to desktop and server applications - not embedded
>>>>> devices]
>>>>> 
>>>> 
>>>> Is there a way for native 64bit application to load a 32bit 
>>>> library, that then can talk to a 32bit USB driver ? (on
>>>> Windows)
>>> 
>>> Drivers (at least kernel mode drivers) must be 64-bit on 64-bit 
>>> Windows (and also basically every other system I'm aware of).
>>> However it's perfectly possible to talk with a 64-bit driver from
>>> a 32-bit application. And no, you can't load a 32-library from a
>>> 64-bit process.
>> 
>> This one is not a kernel-mode (at least so I think because the
>> same installation succeeds both on 32bit XPSP3, and in recent Win10
>> 64bit)...
>> 
>> (it's the old old Microchip MCHPFUSB driver used e.g. with
>> PIC18F4550, driver version 1.3; it's probably not as much a
>> 'driver' as a way to register the PID and VID with the system, more
>> or less; but the library interfacing it, is 32bit only)
> 
> From what I can see from their site version 1.3 is the first that
> supports 64-bit and it indeed includes a 64-bit driver (and a 32-bit
> one as well). Also if I understand that correctly the source and API
> information to access the driver is provided as well, so you could
> either compile the library for 64-bit or port it to FPC to solve
> this.
> 

Thanks for diving into this :) even though you didn't have to.

Confirmed, the distribution of this driver I am using, 
does contain the 64bit .sys file... and the source code (made in Borland C)
for the .dll. They only provided precompiled 32bit dll by default though. 
At least in the download I currently use.

I will come back to this, when I have some time freed after the current 32bit
backend I am writing now, hits a certain milestone ;)

> Regards, Sven

Kind Regards
-L.

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

Re: [fpc-pascal] FPC 64bit for windows

2017-05-19 Thread Lukasz Sokol
On 19/05/17 13:33, Sven Barth via fpc-pascal wrote:

>>> You don't have to build a 32-bit FPC because an official
>>> released installer exists. So this is no problem at all. But
>>> seeing as pretty much everything is moving (or already has moved)
>>> to 64-bit, why bother with 32-bit these days. [referring to
>>> desktop and server applications - not embedded devices]
>>> 
>> 
>> Is there a way for native 64bit application to load a 32bit
>> library, that then can talk to a 32bit USB driver ? (on Windows)
> 
> Drivers (at least kernel mode drivers) must be 64-bit on 64-bit
> Windows (and also basically every other system I'm aware of). However
> it's perfectly possible to talk with a 64-bit driver from a 32-bit
> application. And no, you can't load a 32-library from a 64-bit
> process.

This one is not a kernel-mode (at least so I think because the same
installation succeeds both on 32bit XPSP3, and in recent Win10 64bit)...

(it's the old old Microchip MCHPFUSB driver used e.g. with PIC18F4550, driver 
version 1.3;
 it's probably not as much a 'driver' as a way to register the PID and VID with 
the system,
 more or less; but the library interfacing it, is 32bit only)

-L.

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


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

Re: [fpc-pascal] FPC 64bit for windows

2017-05-19 Thread Lukasz Sokol
On 19/05/17 11:15, Graeme Geldenhuys wrote:
> On 2017-05-19 00:38, Nikolay Nikolov wrote:
>> windows OS - there are simply no known issues with that under any
>> 64-bit windows version that I know of. snip... It won't work
>> from the IDE, though, but compiling your program from the command
>> line, when you want to build a 64-bit .exe shouldn't be hard.
> 
> So you are contradicting your self a bit. No known problems, and then
> two paragraphs later... but there is this known problem with the IDE.
> ;-)
> 
> 
>> Because it is inferior, since it cannot build a 32-bit FPC.
> 
> You don't have to build a 32-bit FPC because an official released
> installer exists. So this is no problem at all. But seeing as pretty
> much everything is moving (or already has moved) to 64-bit, why
> bother with 32-bit these days. [referring to desktop and server
> applications - not embedded devices]
> 

Is there a way for native 64bit application to load a 32bit library,
that then can talk to a 32bit USB driver ?
(on Windows)

-L.

> 
> 
> Regards, Graeme
> 


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

Re: [fpc-pascal] SpVoice.GetVoices returned exception class EOleSysError

2017-04-12 Thread Lukasz Sokol
On 12/04/17 13:37, nore...@z505.com wrote:
> On 2017-04-12 07:01, fredvs wrote:
>> Hello.
>> 
>> There is also a free-open-source project : espeak : 
>> http://espeak.sourceforge.net
>> 
>> The licence is GNU General Public License so you may use the
>> executable like you want.
> 
> The GPL is a restrictive license, so you may not use it like you
> want..
> 
Don't want to sound like a GPL zealot, b/c I'm not...

but this (and below) is mostly 'depends' : on how you want the 
software model to work, how do you value feedback, and how do you
care of people taking advantage of your code in various ways,
without you knowing it.

There, that's about as neutral as I dare to name it ;)

(I also tend to trust GPL/LGPL/MPL released programs more than I'd do
 with anything 'less restrictive' - from end user perspective)

> LGPL would be more close to "like you want" but not really ;-)
> 
> As you know, mit/bsd is really "like you want" license ;-)
> 
> So espeak really is a gpl 2/3 and not LGPL? They are limiting their
> audience a lot...
> 

-L.

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

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-06 Thread Lukasz Sokol
On 05/04/17 17:55, Bart wrote:
> http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random
> 
> "random returns a random number between 0 and abs(num-1)"
> 
> IIUC, then Random() shoud always return a positive number.
> 
Mmm, I don't think so:

For y := Random(num);

the unsigned value of 'y' will will between 0 and abs(num-1) - inclusive,
but then, the value returned keeps the sign of num;

(this as per FPC implementation)

I like Giuliano's definition, it is brief and beautiful:

>> Random(L) returns a random number in the range 0 (included) to L 
>> (excluded). 

(maybe with a similarly brief and concise remark: 'regardless of the sign of L'


> Bart

-L.


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

Re: [fpc-pascal] WebAssembly Target

2017-03-16 Thread Lukasz Sokol
To all who received my previous message through mailing list: 
please disregard. posted without reading thoroughly. apologies.

-L.

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

Re: [fpc-pascal] WebAssembly Target

2017-03-16 Thread Lukasz Sokol
Hi,

On 15/03/17 16:58, Karoly Balogh (Charlie/SGR) wrote:
> Hi,
> 
> On Sun, 12 Mar 2017, Michael Van Canneyt wrote:
> 
>>> Is there something planned in this matter for FPC?
>>> 
>>> I was reading about the new Firefox making WebAssembly publicly 
>>> available ("On Tuesday Firefox 52 became the first browser to
>>> support WebAssembly
>>> 
>> ")
>>>
>> 
[1] .
>> 
>> Karoly Balogh (Charlie/SGR) is working on this, and as far as I
>> know has already some degree of success. There is a bounty for
>> initial webassembly support..
> 
> Well, "degree of success" is relative, I have added WASM target to
> the compiler so it compiles at least. I even made it output 1 single 
> instruction... :)
> 
> It's based largely on gutted JVM codegenerator code, although since 
> WebAssembly itself is still a moving target, many things are still 
> uncertain. There's also the problem, that despite it's name,
> WebAssembly is not really an assembly format, but just a stack based
> bytecode (much like JVM), and the official textual representation is
> not yet accepted, plus the reference compiler LLVM outputs something
> entirely different to the semi-official textual formats. And these
> official textual formats are quite painful for the traditional
> structured compiler layers like FPC has.
> 
> But the LLVM-style output would be good, but it's undocumented, and
> as they say it will go away, and LLVM will output the binary
> bytecode directly... (Which is stupid IMO, but hey, a comittee
> decided, so it must be right.)
> 
> Also, any "assembler" or toolchain is still in its infancy. (I made
> both binaryen and wabt segfault in several funny ways already.) So I
> wouldn't expect fast results with this whole target. But I will keep
> working on it as time allows, so "eventually"... Of course if someone
> thinks he can proceed faster and wants to jump in, it's very
> welcomed.
> 
> It's now committed to the webassembly branch in FPC SVN, the
> compiler itself should build at least as "wasm" target, but don't
> expect much.
> 
> Charlie 


Just because of curiosity: since Firefox  52 apparently boasts (to be the first 
browser with)
WebAssembly support - 
- i know, i know, just because one vendor claims it, it doesn't mean anything 
yet - 
-maybe something concrete could be derived from that fact? Even if it's just a 
'how do they do it' style of fact.

(in the press release they say something about Emscripten being the reference 
implementation, if that helps)

-L.
(rs,ianad)

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

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-08 Thread Lukasz Sokol
On 07/03/17 23:03, Vojtěch Čihák wrote:
> Hi,
> 
>  

intersting,

> 
> there are different informations about *.wav, so maybe there are different 
> impementations too.
> 
> See:
> 
> http://soundfile.sapp.org/doc/WaveFormat/
> 

This also has endiannes information, which is quite cool..

> and
> 
> https://blogs.msdn.microsoft.com/dawate/2009/06/23/intro-to-audio-programming-part-2-demystifying-the-wav-format/
> 

and this one, seems to be saying the data and file size fields are 32 BYTES 
(emphasis mine) long.

>  
> 
> The first says that 8-bit is unsigned, the second says signed.
> 
> The first does not mention floats, the second says 32-bits but only -1.0 to 
> 1.0.
> 
>  
> 
> V.

-L.

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

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-07 Thread Lukasz Sokol
Hi,

On 07/03/17 13:23, Michael Van Canneyt wrote:
> 
>> Huh? Of course you can do that rather similary in C as well.
> 
> Indeed. You can do exactly the same. You can do this:
> 
> {$mode objfpc}
> uses classes;
> 
> 
> Type
>   Float = Double;
>   TFloatArray = Array of Float;
> 
> Procedure TestRW(X : TFloatArray);
> 
> Var
>   F : TFileStream;
>   Y : TFloatArray;
>   I : Integer;
> 
> begin
>   // Write
>   F:=TFileStream.Create('float.dat',fmCreate);
>   try

so here is what I am seeing in Fre;D's code, that he managed to paste in one of 
the previous
messages :

// "FileBuffer.Data.Seek(0, soFromBeginning);"

  F.Seek(0, soFromBeginning);   /// this it would be in Michaels' code 

I don't think it matters if you newly create the stream... 
looks like something (probably) performed by the constructor already;

(just a stab in the dark here, unless we take the time to look into Fred's 
github ?)

-L.

> F.WriteBuffer(X[0],Length(X)*SizeOf(Float));
>   finally
> F.Free;
>   end;
>   // Read
>   F:=TFileStream.Create('float.dat',fmOpenRead);
>   try
> SetLength(Y,F.Size div SizeOf(Float));
> F.ReadBuffer(Y[0],F.Size);
>   finally
> F.Free;
>   end;
>   // Check
>   If Length(Y)<>Length(X) then
> Writeln('Wrong length')
>   else For I:=0 to Length(X)-1 do
> if (X[i]<>Y[i]) then
>   Writeln('Wrong element at pos ',i,': ',X[i]<>Y[i]);
> end;
> 
> var
>   X : TFloatArray;
>   I : Integer;
> 
> begin
>   SetLength(X,10);
>   Writeln('Floats');
>   For I:=0 to Length(X)-1 do
>  X[i]:=10+(1/(1+I));
>   TestRW(X);
>   Writeln('integers');
>   For I:=0 to Length(X)-1 do
>  X[i]:=10+I;
>   TestRW(X);
> end.
> 
> Michael.


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

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Lukasz Sokol
Or, quite comically maybe: use a text file... write/writeln and read/readln,
and use zip compression on the text file to compress data...

-L.

On 06/03/17 15:59, Lukasz Sokol wrote:
> On 06/03/17 14:50, fredvs wrote:
>>> I don't know. By all logic, it should not work either.
>> 
>> OK, It comes from a "lucky" bug (thanks to reveal it). There was a
>> setlength(buffer, length(buffer) * channels) not needed.
>> 
>> Ok, fixed.
>> 
>> But the problem remain:
>> 
>> If data are int16 or int32: OK, the file is created with +- 1 mega
>> bytes and I can get those data back.
>> 
>> But if data are float32: NOT OK, the file is created but with only
>> 6 octets ;-( .
>> 
>> For example,
>> 
>> for x :=0 to length(bufferfloat) -1 do bufferfloat[x] := 127 ; //
>> for int16 ---> it works
>> 
>> for x :=0 to length(bufferfloat) -1 do bufferfloat[x] :=
>> 2147483646;  // for int32 ---> it works
>> 
>> for x :=0 to length(bufferfloat) -1 do bufferfloat[x] :=
>> 0.2147483646 ; // for float32 > it does not work
>> 
> 
> Looks like for float you'd need a conversion record
> 
> {enable packed records}
> 
> TFloatToBuffer = packed record case boolean of true: FloatField :
> float32; false : BufferField : array[0..3] of byte; end; end;
> 
> for x := 0 to length(bufferfloat)-1 do bufferfloat[x].FloatField :=
> {float value}
> 
> // but then special handling is likely needed to concat the buffer to
> write to file and reading from file // so be careful ;)
> 
> 
> -L.
>> 
>> Fre;D
>> 
>> 
>> 
>> - Many thanks ;-) -- View this message in context:
>> http://free-pascal-general.1045716.n5.nabble.com/Adding-a-array-of-float-in-ressource-and-use-it-tp5727765p5727784.html
>>
>> 
Sent from the Free Pascal - General mailing list archive at Nabble.com.
>> ___ fpc-pascal maillist
>> -  fpc-pascal@lists.freepascal.org 
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>> 
> 
> 
> ___ fpc-pascal maillist
> -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> 


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

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Lukasz Sokol
On 06/03/17 14:50, fredvs wrote:
>> I don't know. By all logic, it should not work either.
> 
> OK, It comes from a "lucky" bug (thanks to reveal it).
> There was a setlength(buffer, length(buffer) * channels) not needed.
> 
> Ok, fixed.
> 
> But the problem remain:
> 
> If data are int16 or int32: OK, the file is created with +- 1 mega bytes and
> I can get those data back.
> 
> But if data are float32: NOT OK, the file is created but with only 6 octets
> ;-( . 
> 
> For example, 
> 
> for x :=0 to length(bufferfloat) -1 do 
> bufferfloat[x] := 127 ; // for int16 ---> it works
> 
> for x :=0 to length(bufferfloat) -1 do 
> bufferfloat[x] := 2147483646;  // for int32 ---> it works
> 
> for x :=0 to length(bufferfloat) -1 do 
> bufferfloat[x] := 0.2147483646 ; // for float32 > it does not work  
> 

Looks like for float you'd need a conversion record

{enable packed records}

TFloatToBuffer = packed record
  case boolean of
true: FloatField : float32;
false : BufferField : array[0..3] of byte;
  end;
end;

for x := 0 to length(bufferfloat)-1 do
  bufferfloat[x].FloatField := {float value}

// but then special handling is likely needed to concat the buffer to write to 
file and reading from file
// so be careful ;)


-L.
> 
> Fre;D
> 
> 
> 
> -
> Many thanks ;-)
> --
> View this message in context: 
> http://free-pascal-general.1045716.n5.nabble.com/Adding-a-array-of-float-in-ressource-and-use-it-tp5727765p5727784.html
> Sent from the Free Pascal - General mailing list archive at Nabble.com.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> 


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

Re: [fpc-pascal] fpc and voip ?

2017-01-17 Thread Lukasz Sokol
On 17/01/17 09:04, José Mejuto wrote:
> El 16/01/2017 a las 23:10, fredvs escribió:
> 
> Hello,
> 
>> What must be done to make: - a url-mp3-file like 1) on server
> 
[...]
> In the other side, mp3 is not a suitable format for voIP, as it have
> a big latency.
> 
Yeah, Fred mentioned VoIP, that's why I thought of a real VoIP application to 
look at inspiration first..

(I happen to know... 
 the names or commonly used codecs for VoIP: alaw, ulaw, gsm ;) - they are 
apparently supported in the program I pasted a link to)

-L.

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


Re: [fpc-pascal] fpc and voip ?

2017-01-16 Thread Lukasz Sokol
On 16/01/17 16:02, fredvs wrote:
> Hello.
> 
> Thanks Lucaz for the link.
> 
> But this is too complete !
> 
OOps :)

> I will try to explain what i want and if it is possible to do it with
> fphttpclient/server.pas.
> 
> I can successfully save to file input from mic/wav/mp3/ogg/flac to wav file.
> 
> Is it possible that this file, while recording, could be accessible as a
> URL-file ?

I thought about it a bit... isn't this how YouTube Live Stream or Twitch and 
alikes somehow works?
Maybe your inspiration can come from there ? 
These usually require 'special' client-side programs anyway, be it a 
flash-based or HTML5 video player ... 
aka, not a 'normal' file-stream downloader. 

> And that  URL-file could be accessed by TThreadHttpGetter +fphttpclient.pas
> ?

If you can feed the HTML5  source from fphttpclient hmm, that could be 
what you're after?
(provided they don't need SPDY for example, cause that's a bit different than 
HTTP [actually IIRC nowadays HTTP/2 it's called?])

> 
> PS: I am not pro in web-stuffs... ;-(
> 
Me Neither :J

> Fre;D
> 

 -L.

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


Re: [fpc-pascal] fpc and voip ?

2017-01-16 Thread Lukasz Sokol
On 14/01/17 13:05, fredvs wrote:
> Hello.
> 
> I have lot of success to play mp3 files with library mpg123+portaudio and
> fpc unit fphttpclient.pas.
> 
> Andrew Haines did a perfect work with his TThreadHttpGetter (that is now
> included in https://github.com/fredvs/uos).
> 
> So getting the voice over ip is not a problem.
> 
> For sending the voice, portaudio library and a input device is used.
> 
> But what is the best way to finish the circle ?
> 
> IMO, compress the microphone-wav-chunck into mp3 (with lame-mp3 encoder for
> example) and then... ?
> 
> What fpc unit should I use to make that wav-chunck-compressed ready to use
> for TThreadHttpGetter ?
> 
> A sample code will be very welcome.

This is not written in FPC or Delphi, but in BDS (C++) - 

http://tomeko.net/software/SIPclient/index.php?lang=en

but there are sources too (and uses portaudio for input too, IIUC)

> 
> Thanks.
> 
> Fre;D
> -
> Many thanks ;-)

-L.

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


Re: [fpc-pascal] Bls: TProcess failed running Swift compiler

2017-01-09 Thread Lukasz Sokol
Hi Mr Bee,

On 09/01/17 13:34, Mr Bee wrote:
> I found the answer myself. It seems that I need to supply the full
> path to the swift REPL executable. I don't understand why it requires
> it for swift because it could call python executable just fine
> without using full path. Anyway, problem solved. :)
> 
> 
> –Mr Bee
> 

Can you verify what your $PATH environment variable holds for either 
interpreter ? ;)
(just a thought)

-L.


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


Re: [fpc-pascal] Resource strings, passwords etc.

2016-07-13 Thread Lukasz Sokol
On 13/07/16 08:31, Mark Morgan Lloyd wrote:
> Michael Van Canneyt wrote:
>> On Tue, 12 Jul 2016, Mark Morgan Lloyd wrote:
>>
>>> Please excuse one of my regular silly questions. Elsewhere, a (former) 
>>> Delphi programmer is uneasy having found that his binaries have had 
>>> embedded SQL queries, passwords and so on visible "in clear" for the last 
>>> 20 years or so.
>>>
>>> Can FPC be told to obfuscate ResourceStrings?
>>
>> No. The default value for resourcestrings is stored as-is in the binary.
>>
>> To solve this, I store the username/password encrypted in the binary as 
>> consts, and they are decrypted when needed.
> 
> Sometimes it's difficult to avoid having to do that sort of thing, or 
> obfuscating them in an external file.
> 

Could it help to try doing this after linking the program binary, to build the 
resources and scramble them
using the program binary part checksum (or have it seed a PRNG and/or derive an 
encryption key / key pair from it) ?

Not that I know how ;) and whether such a thing is viable at all - or desirable 
(since an executable would
always have to be distributed with matching resources build). But how would 
that be for an idea ? ;)

el es

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


Re: [fpc-pascal] Single threaded application on multicore CPU

2016-06-22 Thread Lukasz Sokol
On 22/06/16 08:07, Torsten Bonde Christiansen wrote:
> On 2016-06-22 09:02, LacaK wrote:
>> Hi *,
>>
>> may be that this question is bit off-topic here, but I am sure, that here 
>> are experts, which know answer ;-)
>>
>> I have simple Lazarus/FPC application (with no explicit threads) which does 
>> intensive calculations (local thresholding with big window size) on image, 
>> which is stored into memory as 2D byte array.
>> (so only memory access is done and some integer calculations)
>>
>> When I run this application and look at Task Manager or Resource Monitor I 
>> see, that all 4 cores "are used" (at least performance graph shows usage or 
>> in other words activity in graph increasees)
>> Total CPU usage is <= 25% (which points out to fact, that only 1/4 cores is 
>> used)
>>
>> Why this ? As far as I expect, that single threaded application should use 
>> only one core, so I would expect activity only on one core not on all four 
>> cores
>> (I know that in theory CPU can switch single thread between cores, but I 
>> doubt that this is case (as switching has extra cost)... or is ?)
> 
> Nailed it right there
> 
> All modern CPU automatically swaps running threads (unless affinity is set) 
> to other cores in case there is a high load. This is done from a

^ s/CPU/OS Kernel ;)

> heat perspective, since running on a single cores will make a local heat spot 
> on the dye - a things which is not prefered and also not really
> cost effient.
> 
>> (Btw: When I set affinity to only one core, then this core is 100% and 
>> others are 0% as expected)
>>
> 
> -Torsten.

-L.

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


Re: [fpc-pascal] TFPList.Expand was: Maximum of memory which can be used by single program in 32 bit Windows

2016-05-20 Thread Lukasz Sokol
On 20/05/16 09:40, Graeme Geldenhuys wrote:
> On 2016-05-20 09:36, Graeme Geldenhuys wrote:
>> I think a “x percentage of capacity” increment is the way to go. eg: 5
>> or 10%
> 
> Scrap that idea. In hind sight, % increments is what is causing the problem.
> 
> Regards,
>   Graeme

And actually why not 'just' allocate exactly what is needed on demand ? May be 
slower but
even less overhead.

-L.


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

Re: [fpc-pascal] Build in a C compiler

2016-04-21 Thread Lukasz Sokol
On 20/04/16 15:04, Rainer Stratmann wrote:
> Am Mittwoch, 20. April 2016, 12:40:19 schrieb Mark Morgan Lloyd:
>>> http://www.mikroe.com/compilers
>>
>> If you want to believe that BASIC- as originally implemented- and ALGOL
>> are related then go ahead and do so. But the politest thing I can say is
>> that it doesn't make you look particularly well-informed.
> 
> You can go to the company and say poliltely to them that they are not well 
> informed. I don't know if they take you serious.

Existence of Pascal front-end / parser/ IR creator for any compiler suite (e.g. 
clang, GNU, whatever)
does /not/ /really/ prove anything of the sort of you are implying.

-L.






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


Re: [fpc-pascal] Wiki etc.- where? [ot]

2016-02-25 Thread Lukasz Sokol
On 25/02/16 14:37, Mark Morgan Lloyd wrote:
>  I was hoping to use to resurrect LinuxPMI (OpenMOSIX) 

Wow, I remember trying to boot up a cluster of OpenMOSIX machines
from CD's (remastered Knoppix) :) back in 2004 ;)

Not much left of that world any more, sadly; since the OM creator abandoned the 
project...

There was a continuation, https://en.wikipedia.org/wiki/LinuxPMI...
not sure where that ended though.

-L.

(shall we fut: g.c.c.f-p.social aka fpc-other :) ?)

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


[fpc-pascal] [OT] News-Flash: fpc-other is now on Gmane !

2016-02-19 Thread Lukasz Sokol
Yay 

http://dir.gmane.org/gmane.comp.compilers.free-pascal.social

However has not yet hit the gmane nntp hierarchy (at the time of writing this 
post);

The first post it lists is the Lazarus 1.6 Announcement
Date: 2016-02-18 15:28:27 GMT (18 hours and 21 minutes ago)

So I could not subscribe to it with my Thunderbird (yet).

(this apparently is /not/ something I could filter out of the Gmane FAQ,
other than it can take up to 2 weeks since subscribtion - 
so I guess a post to gmane.discuss would be in order, but let's give
them some more time. Say, next week?)

But this is very welcome anyway :)

-L.

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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
Hi,

On 04/02/16 21:33, Michael Van Canneyt wrote:
> 
> 
> On Thu, 4 Feb 2016, Felipe Monteiro de Carvalho wrote:
> 
>> Disappointed :(
> 
> Well, such is life. I'm also disappointed that my bank account doesn't 
> contain millions. But I learned to live with it :-)
> 
> But all hope is not lost yet.
> 
>> Why was it done? I thought that pretty much everyone was in favor?
> 
> Not quite, form was also deemed important. It is a tricky balance.
> 
> To recapitulate:
> 
> There were various choices:
> 
> a) not adding at all
> b) a ? b : c
> c) if a then b else c
> d) iif()(or some variant thereof)
  
what of
  e) some kind of assignment, requiring use of braces, e.g. 
   x :=  ( if condition then truevalue else flasevalue );
or
   x :=  ( condition then truevalue else falsevalue );

... ?

It also does not clash with function names, only reuses same keywords...

> 
> From the people that responded in the core discussion, the majority was for 
> the a ? b : c
> syntax, or not adding at all (not all replied).
[...]

> Sven simply didn't want to implement the a ? b : c form.
> 
> This should be respected, each works on what (s)he wants to work.
> That is not to say that all work done is automatically and irrevocably added 
> to the compiler.
> 
> Experiments can be done, but can also be discarded.


> 
>> It isn't very pascalish, that's true, but we could implement it like
>> the proposed "inline if A then B else C" syntax... which is very
>> pascalish and cool.

So might be the 'assignment', no?

> 
> 'Cool' is a very personal appreciation. Some men like blondes, others prefer 
> redheads or brunettes.
> 
> For example, I don't think this is pascalish or cool.
> 
> Rationale for protest (there may have been other reasons beside the below):
> 
> "if then" is a statement. This is a clear and unambiguous rule.
> 
> Allowing "if then" as part of an expression is introducing ambiguity and 
> error prone.
> 
> Samples of non-desirable constructs include:
> 
> Type
>   TMyArray = Array[1..if sizeof(integer)=2 then 4 else 5] of integer;
> 
>   myconst = if sizeof(integer)=2 then 4 else 5;
> 
>   Procedure Something(AA : Integer = if sizeof(integer)=2 then 4 else 5);
> 
>   Property A : Integer Index if sizeof(integer)=2 then 4 else 5 read geta;
> 
>   Property B : Integer Read FA Write FA default if sizeof(integer)=2 then 4 
> else 5 ;

I believe the assignment form would get rid of the above... because one can't 
use an := assignment in a declaration right?

> 
> And - in my eyes - the topper in horror:
> 
>   if if if a then b else c then e else g then
>  DoSomething
>   else if if h then i else j then
>  DoSomethingElse;
> 

and convert this into
x := (((a then b else c) then e else g) then DoSomething else DoSomethingElse);
(

well actually looking at this abuse it doesn't seem to be likely to work 
...?
unless someone does

x := (y := ( z := (a then b else c) then e else g ) then DoSomething else 
DoSomethingElse);

so the immediate y,z variables have to be declared.
(and also requires a,b,c,e,g be boolean)

but quoting "everything can (and will) be abused" duh ;)

[...]

> That about sums up what was said about this in core.
> 
> As you see, it is not necessarily permanently off the drawing board, but has 
> definitely been put in the (deep) freezer.
> 
> Michael.

Just my PLN 0.02.

el es

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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 09:48, Marco van de Voort wrote:
> In our previous episode, Lukasz Sokol said:
>> What of
>>
>> x := ( condition, true:=truevalue, false:=falsevalue);
> 
> Clashes too much with _() from dxgettext.
> 

Uh, ok. 
then what about double braces (( and )) ? Oh and using ';' for condition and 
values separation, not ',' like above...?

el es


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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 10:35, Andreas wrote:
> 
> On Fri 05/02/2016 07:49, Lukasz Sokol wrote:
>> That it's C, not Pascal ;) and, um. sorry I do not have a c spec on hand, 
>> does it really work that way in C - only evaluates truevalue or falsevalue 
>> not both?
>>
>> I wrote another one in another email, maybe actually having new keyword or 2 
>> is ok ?
>> and require it to be an assignment, like
>>
>> x := ( condition; whentrue:=true_value; whenfalse:=false_value);
>>
>> so syntactic sugar but not abusing function calls, but an assignment instead.
>>
> Well then how about: x *:=* *when* condition true_condition *otherwise* 
> false_condition;
> 
> How this is pascalish.
> 
Smells, like perl or python... I almost wrote the 'when version' but... ;)

without clear indication that a value is returned, it's like a statement... 

Any other imaginative way to indicate that a construct returns a value, other 
than using braces...?
as 'just braces' will confuse people using _() a lot.

(side note : 
x := (when condition use truevalue otherwise falsevalue); 

looks more like : keyword before expression template; needs 3 keywords however. 
and still looks like a statement...


) 

> Andreas
> 
el es


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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 09:45, Michael Van Canneyt wrote:
> 
[...]
>> so I think no /current/ keywords would be allowed either... I see.
> 
> Anything that spells 'statement' is indeed going to meet with fierce 
> resistance.
> 
>>
>> What of
>>
>> x := ( condition, true:=truevalue, false:=falsevalue);
> 
> Apart from any parsing difficulties this may present, what is the benefit over
> 
>   x:=condition ? truevalue : falsevalue
> 
> The latter being the generally used one ?
> 
That it's C, not Pascal ;) and, um. sorry I do not have a c spec on hand, 
does it really work that way in C - only evaluates truevalue or falsevalue not 
both?

I wrote another one in another email, maybe actually having new keyword or 2 is 
ok ?
and require it to be an assignment, like

x := ( condition; whentrue:=true_value; whenfalse:=false_value);

so syntactic sugar but not abusing function calls, but an assignment instead.

> Michael.

el es

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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 11:22, Tomas Hajny wrote:
> Hello everybody,
> 
> Since we're getting back to the same sort of discussion, I'd like to
> remind three statements (before closing this thread here similarly to the
> other two):
> 
[...]
> Tomas
> (one of the FPC mailing list moderators)

Will you or other moderators, accept a request of subscription of fpc-other
coming from either automated process on gmane.org or from gmane admins?

I believe fpc-other would be a worthy addition on gmane.org.

(If only to keep the likes of me from ranting)

Not sure whether the signup has to be handled by a moderator,
but if so, please do allow posting through gmane too.

If the subscribe/signup by Gmane can be performed by non-admin, 
I am giving my hands-up for  it (might happen today, or somewhere next week, 
time allowing).

Kind Regards
el es


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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 12:26, Jonas Maebe wrote:
> 
> Lukasz Sokol wrote on Fri, 05 Feb 2016:
> 
>> Will you or other moderators, accept a request of subscription of fpc-other
>> coming from either automated process on gmane.org or from gmane admins?
>>
>> I believe fpc-other would be a worthy addition on gmane.org.
> 
> After your previous mail about this, I filled in the request form on their 
> site. I have heard nothing back.
> 
Thanks Jonas. 

I never did that before. Maybe they are understaffed ;) 

Thanks anyway; Next week we can start poking at their email addresses ;)

> 
> Jonas

-L.

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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol


On 05/02/16 07:03, Sven Barth wrote:
> Am 04.02.2016 23:43 schrieb "Martin"  >:
>>
>> On 04/02/2016 22:13, Michael Van Canneyt wrote:
>>>
>>>
>>> On Thu, 4 Feb 2016, Felipe Monteiro de Carvalho wrote:


 You mean like literally using "?" and ":" ?
>>>
>>>
>>> Yes. As used in C-like languages.
>>
>>
>> There was also voices for a more verbose solution.
>>
>> But introducing 2 new operators based on words (a-z, not 16 bit) means 2 new 
>> keywords and causes conflicts.
>> Except if "then" and "else" are used (but without "if")
>> x := 1 < 3 then 5 else 4;
> 
> No. Think about the ambiguities that arise if you use this inside the 
> condition of an if-statement.
> 
What if it required use of braces:

x := (expression then truevalue else falsevalue); 

?
> Regards,
> Sven
> 

el es


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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 09:23, Michael Van Canneyt wrote:
> 
> 
> On Fri, 5 Feb 2016, Lukasz Sokol wrote:
> 
>>>> But introducing 2 new operators based on words (a-z, not 16 bit) means 2 
>>>> new keywords and causes conflicts.
>>>> Except if "then" and "else" are used (but without "if")
>>>> x := 1 < 3 then 5 else 4;
>>>
>>> No. Think about the ambiguities that arise if you use this inside the 
>>> condition of an if-statement.
>>>
>> What if it required use of braces:
>>
>> x := (expression then truevalue else falsevalue);
> 
> Let's make it simple:
> 
> The use of "if", "then" and "else" are not up for discussion.
> 
Ah ok. 

so I think no /current/ keywords would be allowed either... I see.

What of

x := ( condition, true:=truevalue, false:=falsevalue);

?

> Michael.

el es

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


Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread Lukasz Sokol
On 05/02/16 09:22, Lukasz Sokol wrote:
> Hi,
> 
> On 04/02/16 21:33, Michael Van Canneyt wrote:
>>
>>
>> On Thu, 4 Feb 2016, Felipe Monteiro de Carvalho wrote:
>>
>>> Disappointed :(
>>
>> Well, such is life. I'm also disappointed that my bank account doesn't 
>> contain millions. But I learned to live with it :-)
>>
>> But all hope is not lost yet.
>>
>>> Why was it done? I thought that pretty much everyone was in favor?
>>
>> Not quite, form was also deemed important. It is a tricky balance.
>>
>> To recapitulate:
>>
>> There were various choices:
>>
>> a) not adding at all
>> b) a ? b : c
>> c) if a then b else c
>> d) iif()(or some variant thereof)
>   
> what of
>   e) some kind of assignment, requiring use of braces, e.g. 
>x :=  ( if condition then truevalue else flasevalue );
> or
>x :=  ( condition then truevalue else falsevalue );
> 
> ... ?
> 
> It also does not clash with function names, only reuses same keywords...

An as reusing keywords is a no-no...

I wrote x := ( condition, true := truevalue, false:=falsevalue); in previous 
email;
but since true and false are constants (and reserved names) too,

maybe, actually, a new keyword (pair) would be actually OK ?

x := (condition; whentrue:=truevalue; whenfalse:=falsevalue); ?
 
yes requiring use of assignment, braces, and assignments inside braces. 

[...]
> 
> el es
> 
el es


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


Re: [fpc-pascal] The IfThen() thread is now closed

2016-02-03 Thread Lukasz Sokol
Hi Jonas,

On 02/02/16 18:27, Jonas Maebe wrote:
> Hi,
> 
> I think that everyone has had ample opportunities to exchange their
> views on this topic, so it's now closed on this list. If you want to
> discuss it further, you can do so on the fpc-other list.> 
> Thanks,
> 
> 
> Jonas
> FPC mailing lists admin

would you permit Gmane to subscribe to the fpc-other mailing list, please?

http://gmane.org/subscribe.php, and (I think) the gmane admins might be getting 
in touch.

Kind Regards
el es

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


Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Lukasz Sokol
(bikeshedding mode=on)

On 02/02/16 11:24, Marcos Douglas wrote:
> On Tue, Feb 2, 2016 at 7:49 AM, Michael Van Canneyt
>  wrote:
>> It is not a statement, it is an expression.
>>
>> I prefer
>>   x := iif Obj = nil then 0 else Obj.Value;
>> over
>>   x := if Obj = nil then 0 else Obj.Value;
>>
>> Because it clearly differentiates between if (a statement) and iif (an
>> expression)
>>
>> So the iif in either functional or expression form has my vote.
> 
> +1
> 
> And why not use 'inline'?
> 
>   x := inline if Obj = nil then 0 else Obj.Value;

and what if the definition was

x := (if condition then value1 else value2);

that is REQUIRING round parentheses around this construct - 
no need for 'inline' keyword and compatible with code beautifiers (of sorts) 
and thanks to parentheses, showing exactly it's a statement, returning a value 
like an expression...

> 
> It's not necessary add one more keyword like "iif", I think.
> 
> Best regards,
> Marcos Douglas

el es


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


Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Lukasz Sokol
On 23/12/15 09:37, Santiago Amposta wrote:
> Hello:
> I use fpc 2.6.4 and I have a problem of memory leaks, strange errors,
> etc. Finally I have tracked it to this:
> 
> TSimpleArrayString=object
> List:array of String;
> end;
> 
> TDerivedArrayString=object(TSimpleArrayString)
> other_field:integer;
> end;
> 
> procedure TestSimple;
> var
>  A:TSimpleArrayString;
> begin
>   setLength(A.List,0);
> end;
> 
> procedure TestDerived;
> var
>  A:TDerivedArrayString;
> begin
>   setLength(A.List,0);
> end;
> 
> 
> TestSimple; // Works Fine,
> TestDerived; // rises an exception SIGSEGV on setLength
> 
> What am I doing wrong?
> 
I might be wrong... but I just tried:

stepping into TestSimple in the order OP specified,
hovering over A.List (actually over .List only, see below*)
gives 
  A.List = (0x0)
before setLength

and 
  A.List = ()
after the setLength;

then stepped through to TestDerived,  in which the hover over .List gives

A.List = ()

before setLength,
and an External: SIGSEGV At Address 403CDC when trying to step over setLength

Then if I change the order
TestDerived; // first
TestSimple;  // second

and step through, the A.List in Test Derived is A.List = () from the start, it 
is as-if it was preinitialized?

But then. If I comment out the other_field, both routines pass through with 
A.List = (0x0) in TestSimple before SetLength,
it also seems to pass without a problem and without the * problem below, even 
with A.List = () before and after SetLength.

* problem : with the other_field still IN TDerivedArrayString, 
if I step through the (passing with no error) TestSimple, and hover mouse over 
A, I get a GDB crash.
Regardless which A I hover over (the one in Test Derived does that too, even if 
out of scope 
[execution point currently in the other Test procedure]
Again this does NOT happen with the other_field commented out.

If I run either one Test* procedures at a time between rebuilds, with 
other_field defined,
TestSimple passes with no error,
TestDerived shows .List hovering A.List = (0x1 '=') ; hovering over A 
crashes GDB too;

Say if I only leave TestDerived call, and if I pause execution before 
SetLength, 
hovering over .List in EITHER procedure shows A.List = () (yes even in 
TestSimple which is commented out in main begin..end;)
(and I get GDB crash when hovering over A of either procedure)

BUT.

If I truly comment out the unused procedure, only leaving the one currently 
being tested, like TestDerived,
hovering over .List before SetLength call gives A.List = (0x1 '=')
hovering over A crashes GDB

after rebuild, program completes with NO SIGSEGV.

?

FPC 2.6.4 under Lazarus 1.4.4 from tarball release [ 2015-10-03, svn 49931 
i386-win32-win32/win64 ] under WinXP SP3.

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


Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Lukasz Sokol
On 23/12/15 16:06, Santiago A. wrote:
> El 23/12/2015 a las 16:24, Lukasz Sokol escribió:
>> On 23/12/15 09:37, Santiago Amposta wrote:
>> I might be wrong... but I just tried:
>>
>> ...
> 
> What's the conclusion? As far as I see, there is some kind of bug.
> 
> There is no reason for getting different results depending on  how you
> execute two independent and isolated procedures or if you comment in or
> out an unused procedure.
> 

Puzzled me too, 

also the GDB crashing.

See how the A.List points to memory that contains something? Does using a 
constructor
get that straight?

(also sorry, my post underwent a few revisions, and the 'i might be wrong' 
portion does not
belong where it's found any more ;) )

el es

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

Re: [fpc-pascal] Lack of 'volatile' a serious issue. Any other such caveats?

2015-12-18 Thread Lukasz Sokol
On 17/12/15 14:13, R. Diez wrote:
> Hi all:
> 
[...] 
>
>  And there you go, I haven't quite started yet and I already
> discovered the first serious issue: there is no 'volatile' keyword.
> This matter has been brought up in the past, and it worries me that
> it has just been downplayed.
> 
[...]

(semi-jokingly)

I know FreePascal is not Linux, the Team is not Torvalds etc ;)
but have you seen this ? 

https://lwn.net/Articles/233482/

[...]
> 
> Therefore, before I delve any deeper: are there any other serious
> drawbacks that I should know about before I invest more time looking
> at FreePascal?
> 

(again, semi-jokingly)
It's Free and Open Software. You too can send a patch/suggestion ;)

> Regards, rdiez


el es

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


Re: [fpc-pascal] Building kernel modules using fpc (for fun)

2015-11-30 Thread Lukasz Sokol
Hello Paul,

On 28/11/15 21:42, Paul Breneman wrote:
> On 01/23/2011 08:15 AM, Lukasz Sokol wrote:
>> Lukasz Sokol <el.es.cr@...> writes:
>>
>> I decided to put the result of my fiddling back onto the wiki
>> http://wiki.freepascal.org/linux/kernel/module_development  as the pastebin
>> seems to have disappeared mysteriously.
>>
>> Enjoy!
>>
>> Lukasz
> 
> I couldn't find anything but the above wiki page which is almost 5 years old. 
>  I might want to make an example for this wiki page:
>   http://wiki.freepascal.org/Small_Virtual_Machines
> 
> Any suggestions or links?
> 

Wow... it's been years since I did anything in this area.

All I ever tried or knew, and the example module using printk, is only on that 
one page.

Contributors are welcome...

(I never had communicated anything with the original author, Mazen Neifer,
 if he's still around - which I think so - he could link / keyword you more, I 
suppose)

> Regards,
> Paul
> www.ControlPascal.com

Lukasz

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


Re: [fpc-pascal] Access GPIO pins on RPi2 without root? [lenghty and very [OT] ]

2015-10-09 Thread Lukasz Sokol
On 09/10/15 08:50, Bo Berglund wrote:
> On Thu, 08 Oct 2015 22:01:49 +, Mark Morgan Lloyd
>  wrote:
>>> Sorry for causing a problem here...
>>> The lists you refer to are not present in the Gmane newsserver as a
>>> newsgroup so I cannot access it.
>>
>> I suggest setting up a direct subscription using the instructions given 
>> at http://www.freepascal.org/maillist.var  Things like Gmane are really 
>> only useful as long-term archives.
> 
> Well, I don't like to have my inbox receive the number of emails on a
> list like this. The new interface is a much better way in my view.
> I already receive 100+ emails every day so doubling this seems not to
> be a good way for me
> 
I second that,
especially thread.gmane.org is nice - also one can use the mail to news gateway,
through any news/reader/mua (like I use thunderbird).

Bo, how about if we petition the gmane admins to subscribe to fpc-other?
There is a lot of discussion that seems to be going on there. 
 If you write one like that, you've got my vote too.

(and sorry to the list admins, for bringing it on this list/topic, 
gmane tries to obfuscate senders emails when using the mail-to-news gateway)

>>> I will try to locate an updated pigpio.pas file by asking in the
>>> Lazarus forum instead.
>>
>> I would strongly suggest going through /sys/class/gpio first, since you 
>> can exercise it using  echo  and there are fewer things to get wrong.
> 
> I have seen you mention "echo" a number of times and I have gone back
> (in the Gmane gmane.comp.compilers.free-pascal.general news archive in
> my newsreader) to locate the exact method for this but I failed.

(again sorry to the admins here that this may be lengthy and ot, but Bo's email 
has been garbled by Gmane)

'echo' is a distribution-contained (usually a separate program, but that 
depends on the distribution)
that writes its given parameters to std-output, as text, then the '>' redirects 
it to a file.

Long story short, most you need to remember, in unix-like systems everything 
that can be, is treated as a file,
placed under the single virtual file system (VFS) hierarchy. No 'drive 
letters', etc.

When you issue a command 'echo something > /path/to/file' there are several 
things that may happen;
The '>' operation tells the shell to take the echo's std-output and write it to 
the file.
  (OT: if you used >> instead, it would have been added/appended to file; only 
really works on disk for this reason)

In higher-level compiled languages like c or pascal you achieve this by
opening the file, writing to it (possibly preceded by doing a 'rewrite' it, but 
not sure) and then closing.
(remember that either of these 3 operations may throw an error which you need 
to handle)

in case of GPIO, the in-kernel driver has VFS hooks that tell it :
 - someone has 'just' replaced the content of the file
in its virtual filesystem hierarchy under /sys/class/gpio/* with 'something', 
so it intercepts that write, interprets/sanitizes what it has been given, 
and handles the userspace programs writing to that file.

It also detects 'reads' from the file similarly, 
some drivers support just reading from a file in a loop, 
by means of likes of: 'open-repeat-read-sleep-untilneeded-close';
but some may need an 'repeat-open-read-close-sleep-untilneeded' pattern; 

there is also a family of *notify system functions/calls, 
but that seems to not be as loved by the system/kernel developers as the 
simpl(istic) open-read-close chain.

It really can't be done any simpler to the userspace, at least in 
Unix-like/Linux world.
it also has interesting implications (regarding permissions)
that this space is really too small and off-topic to contain.

> And I am a total noob in this low level handling of Linux...
> I will continue searching for your echo examples after I return home
> again.
> 

It's not as low-level as kernel, so don't worry ;) 
and yes the information is all over the place and incredibly scattered.
But that's the 'feature' with all the FOSS stuff, it's a myriad of independent 
projects.

el es

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


Re: [fpc-pascal] Access GPIO pins on RPi2 without root?

2015-10-09 Thread Lukasz Sokol
On 09/10/15 09:33, Jonas Maebe wrote:
> Bo Berglund wrote:
>> I have asked about this on the Pi forum instead, but I fear noone 
>> (almost) over there use free-pascal so I have no high hopes.
> 
> The point is that this question is completely unrelated to Pascal or
> Free Pascal. It's a basic Unix/Linux usage question, which is
> independent of the used programming language. If you ask how to
> access "GPIO pins on RPi2 without root" on a Linux/Raspberry forum,
> any answer you will get will equally apply to FPC as to any other
> language. You already have the Pascal code to access the pins from
> the wiki, per a previous post of yours, so you don't have to mention
> FPC/Pascal at all.
> 
> You just mentioned that you don't like to subscribe to mailing lists
> because you already receive many mails. By posting mails on a list
> that are not really on topic, you make that exact same problem worse
> for other people that do prefer to use email rather than use a web or
> nntp interface.
> 

Hi Jonas,

would you support us, writing to Gmane to actually subscribe to
fpc-other mailing list ? 

Gmane is nice not just for storage, I just more like separation of traffic
between my emails and the actual discussions; like in the olden days...
and I'm sorry but forums don't really cut it for me, for various reasons.

el es

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


Re: [fpc-pascal] Access GPIO pins on RPi2 without root?

2015-10-07 Thread Lukasz Sokol
On 07/10/15 08:02, Bo Berglund wrote:
> How can one control the GPIO outputs on a Raspberry Pi2 without
> needing the program to run as root? I am using Raspbian Wheezy and I
> need to add two relays controls to my program.
> The pages I have found with google are for the original Pi so the
> connector referenced is the wrong size and it is also always mentioned
> that the program must be run as root.
> My program must be started every minute by cron so I don't know how
> this will happen...
> (Not so used to Linux)
> 
> Do I need to install some driver in Raspbian to allow access to the
> GPIO ports from FPC?
> 
> 

Apart from running SUID Root, which is generally discouraged (there is lots of 
answers on why setuid root is bad)

I'd probably search for some udev rules to make up - to chown the gpio
devices in /dev to root:gpio, (for example) and your unprivileged user to
be a member of group gpio;

( possibly https://www.raspberrypi.org/forums/viewtopic.php?f=29=9667, but
also worth checking out other 
https://www.google.com/search?q=raspberry+pi+udev+gpio+user=utf-8=utf-8 
results.)

el es

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


Re: [fpc-pascal] How to compile Lazarus program using only FPC?

2015-09-25 Thread Lukasz Sokol
On 25/09/15 16:13, Bo Berglund wrote:
> On Fri, 25 Sep 2015 08:30:10 +, Mark Morgan Lloyd
>  wrote:
> 
>> Bo Berglund wrote:
>>> If absolutely necessary I will have to set up the RPi with a monitor,
>>> keyboard and mouse and install Lazarus and compile from there. But RPi
>>> is not as powerful a computer as the PC and it will probably be very
>>> slow if at all working
>>
>> You /do/ appreciate that you can tunnel the X11 user interface across 
>> SSH, and that most distreaux enable this by default, don't you?
> 
> I have no idea what you are talking about here
> OTOH I have limited exposure to Linux, just installed a few virtual
> machines to get an Apache webserver running for debugging website
> development. And I have used a number of RPi units for specialized
> tasks (media center, VPN and Print servers). The RPi:s are all
> headless except the media center one, which is connected by HDMI to my
> TV. And using a TV as the display does not really appeal to me...
> 
> My series of questions here are caused by me (while travelling) trying
> to collect all info needed for creating a controller application on
> the RPi2 using a half dozen units I earlier programmed in Delphi. Too
> much to rewrite in another language.
> I never programmed anything on a Linux system before.
> 
> 
This seems like a nice tutorial on X over SSH:

http://elinux.org/RPi_Remote_Access

(not tried myself YMMV)

el es

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


Re: [fpc-pascal] Interactive command recognition mapping to program functions other 'cli' features as a unit

2015-08-03 Thread Lukasz Sokol
On 03/08/15 09:36, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 On 31/07/15 16:41, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 On 31/07/15 14:46, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 Hi,

 I tried piecing something like in $topic together,

 intended as an 'interactive' command interpreter for my program. (which 
 will in time grow an 'embedded' web server and intended to
 run as a (windows) service, but it's too early for that at the
 moment)

 Looking at your question another way, I suppose that you also have
 the issue of parsing a command as well as handling the data entry. I
 think that there's various possibilities here depending on what
 you're trying to handle:

 * A simple sequence of names/numbers.

 Supposedly this would do, parameters mostly are numbers (but when parsing
 through a TStringList everything is a string first anyway, so I can define
 some rules as to which parameter is what type)
 
 Parse the first word to an enumeration, feed that to a case. Leave options 
 for terminating characters, case sensitivity and so on.
 

Hmm, yeah, guess I complicated my case 'a bit' by keeping the command/function 
mapping in a static array...
Back to the drawing board ;J

 * A unix-style command line, with leading options.

 Would be nice, however I don't need 'if' or explicitly defined looping 
 instructions...
 
 No, I mean parsing of options starting - or -- together with their 
 parameters. 'if' etc. are part of the shell, so are a distinct issue.
 
Ah, ok. So , no, that's not needed in my case.


Thanks,
el es

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


Re: [fpc-pascal] Interactive command recognition mapping to program functions other 'cli' features as a unit

2015-08-03 Thread Lukasz Sokol
On 31/07/15 16:41, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 On 31/07/15 14:46, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 Hi,

 I tried piecing something like in $topic together,

 intended as an 'interactive' command interpreter for my program. (which 
 will in time grow an 'embedded' web server and intended to
 run as a (windows) service, but it's too early for that at the
 moment)
 

 Looking at your question another way, I suppose that you also have
 the issue of parsing a command as well as handling the data entry. I
 think that there's various possibilities here depending on what
 you're trying to handle:

 * A simple sequence of names/numbers.
 
Supposedly this would do, parameters mostly are numbers (but when parsing
through a TStringList everything is a string first anyway, so I can define
some rules as to which parameter is what type)

 * A unix-style command line, with leading options.

Would be nice, however I don't need 'if' or explicitly defined looping 
instructions...

 
 * A sequence of email/HTTP headers.
 
 * XML.
 
 * Any of the above but with macro and/or numeric evaluation.

This would be nice to have, some commands could 'substitute' a variable 
prefixed with a '$' that they find in the rest of cmdline, for their own output
(like, running other commands in a sequence, but without explicit conditional 
commands)

 
 I note in particular that PostgreSQL uses Flex and Bison, and if
 they'll parse (a fairly comprehensively extended) SQL I guess they'll
 parse about anything. Apart from that I've hacked something together
 for my own use based on Smalltalk (as an outer parser) with various
 evaluation possibilities (as an inner parser), this was intended as a
 way for programs to talk to each other and has its good points.

Hmm seems way too complicated for my purpose(s) ;) But we'll see,

 
 I'm not sure whether getopts from the RTL provides a facility for you
 to feed it an arbitrary string for processing, but it would probably
 be a good place to start. 

I'll have a look.

Thank you,

Kind Regards,
 el es


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


Re: [fpc-pascal] Interactive command recognition mapping to program functions other 'cli' features as a unit

2015-07-31 Thread Lukasz Sokol
On 31/07/15 14:46, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 Hi,
 
 I tried piecing something like in $topic together,
 
 intended as an 'interactive' command interpreter for my program. 
 (which will in time grow an 'embedded' web server and intended to
 run as a (windows) service, but it's too early for that at the
 moment)
[...]
 Any hints, Any keywords, any lmgtfy's are welcome :)
 
 This might be better in the Lazarus mailing list.

Thanks, I'll post there too, however I though i start here...

 
 I've knocked together a special-purpose terminal emulator, it's
 actually an IBM 2741 terminal which uses totally non-standard codes
 internally and I wanted something for APL, early ALGOL
 implementations and so on. This is obviously character-by-character,
 and I was just about able to get something working for TMemo,
 TRichMemo and TListBox. Somebody else mentioned TCmdBox (?) but I
 wasn't able to get it working adequately and in the end discarded
 most of my attempts, it might be worth looking at if you're trying to
 process lines rather than characters.

Will check TCmdBox... thanks!


 
 I think this was discussed a few months ago, and consensus was that
 there wasn't an adequate terminal emulator component. See below.
 
 http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Xterm-konsole-etc-td4031905.html


From the above thread, http://wiki.freepascal.org/CmdLine popped up which I 
think of looking at.

Thanks again,


el es

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


[fpc-pascal] Interactive command recognition mapping to program functions other 'cli' features as a unit

2015-07-31 Thread Lukasz Sokol
Hi,

I tried piecing something like in $topic together,

intended as an 'interactive' command interpreter for my program.
(which will in time grow an 'embedded' web server and intended to run as a 
(windows) service,
but it's too early for that at the moment)

(I hooked some events of a TMemo to my interpreter, 
which currently recognizes commands by a static map/array of record of string 
and function pointers;
and passes the rest of command line to the called function as string, 
then the function is a shim/wrapper over the deeper program functions; 
the entire parameter sanitizing  and conversion from string to what the 
'deeper' function expects,
is done in the 'wrapper' function layer,
and so is the function output converted back to string and spat out to the 
TMemo.

It's growing too complicated to maintain for the purpose, day by day, and has 
problems
with some more interactive commands or tab completion...

Is there something I could use for the purpose that is ready-made, tested, free 
and open source AND of course in FreePascal ?
(I can share my changes back if I do any, can't open the entire application 
though)

Any hints, 
Any keywords,
any lmgtfy's
are welcome :)

Kind Regards
el es

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


Re: [fpc-pascal] Modems etc.

2015-07-27 Thread Lukasz Sokol
On 24/07/15 12:12, Mark Morgan Lloyd wrote:

 
 It turns out that there's a more-or-less off-the-shelf solution in
 SpanDSP http://www.soft-switch.org/ which is one of the libraries
 that underlies IAXmodem. It provides a function to process a block of
 samples, hence a callback to simulate the Rx side of a UART; since
 it's C (rather than C++) it should be possible to mix it with FPC
 code.
 

Cool, bookmarked ;)

Lukasz

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


Re: [fpc-pascal] Modems etc.

2015-07-21 Thread Lukasz Sokol
On 20/07/15 17:32, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 
 It's been years since I had anything to do with DSP, unfortunately,
 but with the FFT running on the sliding 26-sample-long window, and
 a /reverse/ FFT to produce the 26-long sample from just having a
 byte or 2 written to an array, the kind of SIMD processing probably
 won't be very time consuming... and, operating on a fixed size
 array, would be of fixed-processing-time, which is usually handy.
 
 Thanks, noted. I must admit that I've never dabbled directly with
 FFT, but perhaps now is the time to start. I need to do a couple of
 test simulations first to demonstrate that working in the frequency
 domain is more promising than the time domain (I'm having to fight
 off the boss's suggestion that I simply time zero crossings).
 
 Just my £0.02p :) el es
 
 Worth more than you think
 http://www.bbc.co.uk/news/uk-england-berkshire-33586245 :-)
 
:)
Thinking about it some more, it could actually be true that FFT/DFT is overkill.

For detection you need 4 specialized discrete band-pass (1 freq pass) filters,
checking their output 'power' (side note : moving average can be used as 
detector on their outputs)
and you can use them for sending too - just feed them white noise to the input 
:)

there are some advantages to that which this email is too short to contain ;)

el es

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


Re: [fpc-pascal] Modems etc.

2015-07-20 Thread Lukasz Sokol
Hi Mark,

On 18/07/15 17:43, Mark Morgan Lloyd wrote:
 Has anybody used FPC to decode (and generate) FSK modem tones on a
 VOIP connection? Strictly V.21, don't need the complexity of QAM
 etc.
 

i haven't ;) but it's interesting: are you just assembling/decoding 
the ulaw/alaw/choose$codec data into/from 
RTSP and sending/receiving through a SIP voice connection?

How real-time does this need to be, to start with?

el es

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


Re: [fpc-pascal] Modems etc.

2015-07-20 Thread Lukasz Sokol
On 20/07/15 10:49, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 Hi Mark,
 
 On 18/07/15 17:43, Mark Morgan Lloyd wrote:
 Has anybody used FPC to decode (and generate) FSK modem tones on
 a VOIP connection? Strictly V.21, don't need the complexity of
 QAM etc.
 
 
 i haven't ;) but it's interesting: are you just assembling/decoding
 the ulaw/alaw/choose$codec data into/from RTSP and
 sending/receiving through a SIP voice connection?
 
 How real-time does this need to be, to start with?
 
 Real-time enough to simulate a V.21 modem as the backend of a comms
 program running a proprietary telemetry protocol. 

I gather you have more data about this protocol to see where it can handle
the 'processing time' of the far side receiver, and the rest can be just
handled by playing 'recorded audio'.

 Before anybody
 criticises use of an obsolete modem type, I suggest they consider how
 long it takes to set up a V.21 call and transfer a few dozen bytes
 compared with the training time of something more sophisticated.
 

Not criticizing anything ;)

 Leaving aside the call control for the moment, my current thoughts
 are to accumulate G.711 over UDP into a buffer ensuring this is a
 multiple of four samples, 

g711 can be ulaw or alaw IIRC (g711u g711a) ( not sure if this is relevant for 
you,
but the codecs tend to have separate settings entities and even executables in 
any 
audio transcoding software, so I thought I bring this up,
https://en.wikipedia.org/wiki/G.711 )

(if g711 codec is transcoded to/from raw audio maintaining the 8kHz sampling 
rate, 
 then don't you need 26 - 27 samples to fill up the mark/space slot for sending?
 Receiving, you probably need to interpret your filter/fft output whether you 
have enough 
 samples accumulated and levels of the frequency peaks detected, and act on 
that)

 use x86 MMX facilities to extract the
 mark/space frequencies, 
 and something like a rolling average to
 measure which of those is dominant.
 


The wikipedia page has some (pseudo)code on transcoding from g711 to audio 
sample(s),
maybe it could help ? Doesn't seem very complicated ;)

It's been years since I had anything to do with DSP, unfortunately, but
with the FFT running on the sliding 26-sample-long window, and a /reverse/ FFT 
to produce the 
26-long sample from just having a byte or 2 written to an array, the kind of 
SIMD processing probably won't be very 
time consuming... and, operating on a fixed size array, would be of 
fixed-processing-time, which is usually handy.

Just my £0.02p :)
el es

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


Re: [fpc-pascal] Google Code closing down

2015-03-16 Thread Lukasz Sokol
On 14/03/15 12:25, Florian Klaempfl wrote:
 Am 14.03.2015 um 12:45 schrieb Graeme Geldenhuys:
 On 2015-03-14 11:38, Mark Morgan Lloyd wrote:
 [Sigh] I feel like I'm being pushed onto git rather than Subversion.

 Then don't resist it. As 99% of developers would tell you,
 
 [...]
 
 is simply
 the better product. [Graeme runs and hides :-P]
 
 Please make the same poll about C++ and Pascal ;)
 

We all know /the/ answer to that one don't we ;)

I totally could never look at another c compiler ever again :)

el es

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


[fpc-pascal] [total offtopic] Re: Google Code closing down

2015-03-16 Thread Lukasz Sokol
On 16/03/15 11:10, Paul Breneman wrote:
 On 03/16/2015 05:18 AM, Lukasz Sokol wrote:
 On 14/03/15 12:25, Florian Klaempfl wrote:
 Am 14.03.2015 um 12:45 schrieb Graeme Geldenhuys:
 On 2015-03-14 11:38, Mark Morgan Lloyd wrote:
 [Sigh] I feel like I'm being pushed onto git rather than Subversion.

 Then don't resist it. As 99% of developers would tell you,

 [...]

 is simply
 the better product. [Graeme runs and hides :-P]

 Please make the same poll about C++ and Pascal ;)


 We all know /the/ answer to that one don't we ;)

 I totally could never look at another c compiler ever again :)
 
 I've been enjoying getting into C and Python more:
   http://controlpascal.com/picoscope.htm
 

Nice oscilloscopes...
prices, though.
if only Elan were still around...

http://synchrotech.blogspot.co.uk/2013/03/what-happened-to-elan-digital-systems.html

(I have USBScope50... )

el es

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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-10 Thread Lukasz Sokol
On 10/03/15 09:08, Mattias Gaertner wrote:
 On Tue, 10 Mar 2015 08:48:49 +
 Lukasz Sokol el.es...@gmail.com wrote:
 
 On 10/03/15 06:10, Jürgen Hestermann wrote:
 [...]
 Why not simply omit these messages (for managed types)?

 Just because YOU don't need it, doesn't mean it's useless for everybody...

 http://www.freepascal.org/docs-html/prog/progsu80.html#x87-860001.2.80

 why not just use this to suppress the warning JUST where you DO know it's 
 not needed?

 (you can suppress warning by number too IIUC).
 
 Yes.
 For example in Lazarus 1.3+ you can right click the message and
 click on Hide with project option (-vm5089).

Cool, but probably not what I meant ;) as this hides it project-wide ?

I mean, it's good to have this warning enabled by default and only suppress it 
around code
that /I/ know it's bogus at. Otherwise, it /really/ wouldn't serve its purpose 
of pointing
where a PEBKAC^WLOGIC ERROR may occur...

Sort of like surround the variable declaration with 
{$WARN IDENTIFIER OFF}  
{$WARN IDENTIFIER ON}  explicitly (then have code tools fold it so it won't 
pinch our eyes ;) )

 
 Mattias


el es

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

Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-10 Thread Lukasz Sokol
On 10/03/15 13:54, Sven Barth wrote:

 I mean, it's good to have this warning enabled by default and only suppress 
 it around code
 that /I/ know it's bogus at. Otherwise, it /really/ wouldn't serve its 
 purpose of pointing
 where a PEBKAC^WLOGIC ERROR may occur...

 Sort of like surround the variable declaration with
 {$WARN IDENTIFIER OFF}
 {$WARN IDENTIFIER ON}  explicitly (then have code tools fold it so it won't 
 pinch our eyes ;) )
 
 Note: you should use the sequence {$push}{$warn xyz off}bla{$pop} as
 otherwise you would enable the warning if it was disabled from the
 command line parameters or the configuration. 

Thanks, seen this hinted on this m/l before, +1 :)

 Regards,
 Sven

el es


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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-10 Thread Lukasz Sokol
On 10/03/15 16:08, Jürgen Hestermann wrote:
 
 Am 2015-03-10 um 09:48 schrieb Lukasz Sokol:
 On 10/03/15 06:10, Jürgen Hestermann wrote:
 Am 2015-03-09 um 19:24 schrieb DaWorm:
 I would think this part answers that question:  The warning means
 that no value has been */explicitly/* assigned to these variables
 (which */may indicate a logic error/* in the code), not necessarily
 that they contain an unpredictable value. (emphasis mine)


 No, it answer not the question. As I already wrote in my other mail:
 Why am I forced to add superfluous (initialization) code just to get
 rid of a warning that is completely useless (false). Managed types
 *are* initialized so this warning just pollutes the message window
 and distracts from the realy useful information.

 Why not simply omit these messages (for managed types)?


 Just because YOU don't need it, doesn't mean it's useless for everybody...


 Then please tell me, what do you (or anybody else) gain from this warning?
 Especially, as it claims something that is definitely not true (for managed 
 types).
 It may even misguide some to add initialisation code without need and
 it distracts from the realy important messages.
 

Just googled this out:

http://lazarusroad.blogspot.co.uk/2014/02/using-tcomponent-with-automatic.html

and this immediately after:

http://lazarusroad.blogspot.co.uk/2012/07/cost-to-supress-warning-and-how-not-pay.html

el es




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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-10 Thread Lukasz Sokol
On 10/03/15 16:08, Jürgen Hestermann wrote:
 
 Am 2015-03-10 um 09:48 schrieb Lukasz Sokol:
 On 10/03/15 06:10, Jürgen Hestermann wrote:
 Am 2015-03-09 um 19:24 schrieb DaWorm:
 I would think this part answers that question:  The warning means
 that no value has been */explicitly/* assigned to these variables
 (which */may indicate a logic error/* in the code), not necessarily
 that they contain an unpredictable value. (emphasis mine)


 No, it answer not the question. As I already wrote in my other mail:
 Why am I forced to add superfluous (initialization) code just to get
 rid of a warning that is completely useless (false). Managed types
 *are* initialized so this warning just pollutes the message window
 and distracts from the realy useful information.

 Why not simply omit these messages (for managed types)?


 Just because YOU don't need it, doesn't mean it's useless for everybody...


 Then please tell me, what do you (or anybody else) gain from this warning?
 Especially, as it claims something that is definitely not true (for managed 
 types).
 It may even misguide some to add initialisation code without need and
 it distracts from the realy important messages.
 

Just googled this out:
(edit: meant this actually)
http://lazarusroad.blogspot.com.br/2012/07/does-it-matter-how-dynamic-arrays-are.html

and this immediately after:

http://lazarusroad.blogspot.co.uk/2012/07/cost-to-supress-warning-and-how-not-pay.html

el es




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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-10 Thread Lukasz Sokol
On 10/03/15 06:10, Jürgen Hestermann wrote:
 
 Am 2015-03-09 um 19:24 schrieb DaWorm:
 I would think this part answers that question:  The warning means
 that no value has been */explicitly/* assigned to these variables
 (which */may indicate a logic error/* in the code), not necessarily
 that they contain an unpredictable value. (emphasis mine)
 
 
 No, it answer not the question. As I already wrote in my other mail: 
 Why am I forced to add superfluous (initialization) code just to get
 rid of a warning that is completely useless (false). Managed types
 *are* initialized so this warning just pollutes the message window
 and distracts from the realy useful information.
 
 Why not simply omit these messages (for managed types)?
 
 

Just because YOU don't need it, doesn't mean it's useless for everybody...

http://www.freepascal.org/docs-html/prog/progsu80.html#x87-860001.2.80

why not just use this to suppress the warning JUST where you DO know it's not 
needed?

(you can suppress warning by number too IIUC).


el es


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


[fpc-pascal] [Cross-post] Re: Free Pascal and Lazarus Nightly Builds

2015-03-04 Thread Lukasz Sokol
On 03/03/15 17:47, Anthony Walter wrote:
 This is a public notice. Get Lazarus has switched from hosting
 arbitrary revisions to hosting setup programs from nightly builds.
 
 http://www.getlazarus.org/setup/
 
 Going forward each night the current svn trunk sources of FPC and
 Lazarus will be updated and converted into a Windows installer,
 Linux, and Macintosh  archives. The installer, setup scripts,
 application shortcuts, and website have now prominently inform users
 that they have installed or might be installing nightly build
 versions of FPC and Lazarus.
 
 As before any changes get Lazarus makes are hosted in a diff file
 distributed with each install. This information is also mirrored on
 github.
 

Having had a look (as it's a wiki-idea-page-engine), I conclude that the 
automatic
start of download only does not work any more by accident - 
somehow it doesn't go to ?download#linux when I visit it,
but entering http://www.getlazarus.org/setup/?download#linux into URL field 
still does.

Please consider removing the automatic click on the download link PERMANENTLY 
and SURELY.

Going to relevant OS section IS OK.

Forcing users to immediately decide whether to save or not, IS NOT.

My £0.02p.

el es

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


Re: [fpc-pascal] [Cross-post] Re: Free Pascal and Lazarus Nightly Builds

2015-03-04 Thread Lukasz Sokol
On 04/03/15 11:45, Anthony Walter wrote:
 Lukasz. I'm not sure where you are talking about.
 
 I know there's a really big orange button at the top of the screen
 with two words in all caps DOWNLOAD NOW. You're saying you click
 that and something starts to download right away or what some
 colloquially refer to as now? Because if you are, then you've made me
 totally confused. Maybe

in fact IT DOES PROMPT to download with (0.5s delay) after clicking
the Download Now link at the top of (at least Home, but probably also every) 
page.

http://www.getlazarus.org/setup/?download#linux is what appears in my URL bar.

Before some changes were made (did not keep track sorry) that used to happen
on http://www.getlazarus.org/setup too but stopped when you updated page to 
host nightlies.

So as http://www.getlazarus.org/setup does not automatically prompt to download,
but http://www.getlazarus.org/setup/?download#linux does,

I still conclude this is by accident and SHALL BE STOPPED by means of e.g.
commenting out the a.click portions of the script, if you still want to keep the
page jumping to anchor (I've no problem with that):

-
function initDownload(os) {
  var a = getId(os + Install);
  // a.click();  comment this out
}

function checkDownload() {
  var hash = window.location.toString().toLowerCase();
  if (hash.endsWith(?download#windows))
initDownload(windows);
  if (hash.endsWith(?download#macintosh))
initDownload(macintosh);
  if (hash.endsWith(?download#linux))
initDownload(linux);
}

setTimeout(checkDownload, 500);


I reply to it here, as I have made similar (actually, commenting the 
setTimeout) change
on the wiki engine which never made it to the page also I sent it to an email 
pointed on
Contact Us page which has also never even got an acknowledgement.

(OK I can understand you and your moderators are busy, no problem. 
 But it's not just me small time user who did complain about it ... )

 
 Or, is there some other place without the words DOWNLOAD NOW where
 a download happens now and is causing your confusion, such as the
 get Lazarus today link on the front page or the Universal Setup
 link at the bottom of every single page?

No, The behavior described WAS on the Download Now page 
http://www.getlazarus.org/setup/ at the TOP of every page,
by some accident it stopped doing that on an URL without ?download#linux, but
when I actually CLICK on the Download Now, goes to 
http://www.getlazarus.org/setup/?download#linux
and causes my browser to pop me up a question whether where to save it.


Hope you find the above helpful.

Kind Regards
Lukasz

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


Re: [fpc-pascal] fpc-src_2.6.4-140420_i386 from debs at sourceforge : error while processing dpkg install

2015-02-26 Thread Lukasz Sokol

On 26/02/15 15:03, Mattias Gaertner wrote:
 On Thu, 26 Feb 2015 12:12:01 +
 Lukasz Sokol el.es...@gmail.com wrote:


 Ah so I should have uninstalled the 'source' package first... 
 
 Yes.
 I will add a 'Replaces: fpc-source', so that the next fpc-src deb will
 automatically uninstall the fpc-source package.
 
 but will it be a problem if I just leave it as is (with Lazarus1.26 
 seemingly having installed itself 
 parallel to the one from repo (0.9.something), and the sourceforge fpc 
 package also installed without hitches?
 
 It depends on what you do with the sources. Probably it will work for
 you. I'm not sure what happens when you now uninstall one of them. 
 The cleanest solution is: uninstall both and install
 only one of them.
 
Thanks ! :)

 Mattias

Lukasz


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


[fpc-pascal] fpc-src_2.6.4-140420_i386 from debs at sourceforge : error while processing dpkg install

2015-02-26 Thread Lukasz Sokol
I got :

dpkg: error processing fpc-src_2.6.4-140420_i386.deb (--install):
 trying to overwrite 
'/usr/share/fpcsrc/2.6.4/packages/postgres/src/postgres3.pp', which is also in 
package fpc-source-2.6.4 2.6.4+dfsg-4~bpo70+1


while installing the three debs intentionally as replacement of those got from 
the repo;

but it seems to have gone through and Lazarus 1.2.6 has started OK.

Hope this is OK ?

Lukasz

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


Re: [fpc-pascal] fpc-src_2.6.4-140420_i386 from debs at sourceforge : error while processing dpkg install

2015-02-26 Thread Lukasz Sokol
On 26/02/15 11:12, Mattias Gaertner wrote:
 On Thu, 26 Feb 2015 10:09:33 +
 Lukasz Sokol el.es...@gmail.com wrote:
 
 I got :
 
 dpkg: error processing fpc-src_2.6.4-140420_i386.deb (--install):
  trying to overwrite 
 '/usr/share/fpcsrc/2.6.4/packages/postgres/src/postgres3.pp', which is also 
 in package fpc-source-2.6.4 2.6.4+dfsg-4~bpo70+1
 

 while installing the three debs intentionally as replacement of those got 
 from the repo;

 but it seems to have gone through and Lazarus 1.2.6 has started OK.

 Hope this is OK ?
 
 You can install either fpc-src or fpc-source, but not both.

Ah so I should have uninstalled the 'source' package first... 
but will it be a problem if I just leave it as is (with Lazarus1.26 seemingly 
having installed itself 
parallel to the one from repo (0.9.something), and the sourceforge fpc package 
also installed without hitches?


 
 Mattias

Lukasz

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


Re: [fpc-pascal] Some features for FPC 3.0?

2015-02-19 Thread Lukasz Sokol
On 18/02/15 18:18, Florian Klämpfl wrote:
 Am 18.02.2015 um 14:03 schrieb Lukasz Sokol:
[...]
 Unlikely, we even cannot keep pace with the bug reports.
 
I understand. 

[...]
 The linux approach is to dump a source blob onto the user.

And we FPC /users/ are 'suggested' to downloadcompile from SVN (even if it's 
just -fixes)
if whatever our upstream packager provides is insufficient for whatever 
reason...

 I would happily change to this model, unfortunatly we have no
 distributors like linux who do the boring work for us and package fpc
 for ~25 platforms.

OK, so I can see from here, what Marco said, about pseudo releases anyone can 
do,
holds value to the above. That I can understand too. Only hope whoever
volunteers to it, will be able to communicate / convey to upstream and not 
carried
away with their own little world...

Lukasz

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


Re: [fpc-pascal] Some features for FPC 3.0?

2015-02-19 Thread Lukasz Sokol
On 19/02/15 10:13, Sven Barth wrote:
 Am 19.02.2015 10:41 schrieb Lukasz Sokol
 el.es...@gmail.com
 mailto:el.es...@gmail.com:
 
 On 18/02/15 18:18, Florian Klämpfl wrote:
 The linux approach is to dump a source blob onto the user.
 
 And we FPC /users/ are 'suggested' to downloadcompile from SVN
 (even if it's just -fixes) if whatever our upstream packager
 provides is insufficient for whatever reason...
 
 
 You know that Florian was talking about releases? For the Linux
 kernel releases are just source blobs while for us releases are
 mostly binary ones. That's a big difference. 

Yes. 
You are right.
Did I say somewhere, that switching contexts between reading here and reading 
LKML is hard ;)

 The Linux equivalent of
 us suggesting to download and compile from SVN would be to follow
 e.g. linux-next.git, do a pull every now and then and recompile and
 install the kernel.
 

OK.

 Regards, Sven
Lukasz

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


Re: [fpc-pascal] Some features for FPC 3.0?

2015-02-18 Thread Lukasz Sokol
On 18/02/15 11:57, Marco van de Voort wrote:
 In our previous episode, Lukasz Sokol said:
[...]
 You might end up with some people that are less patient instantiating their 
 own git repos, 
 and adopting faster pace, and the main repos becoming outdated... because 
 their downstream 
 patches won't apply to upstream without considerable amount of work.
 
 That simply can't be stopped. It is of course annoying since usually the
 support burden for such projects still falls on the original project (even
 if only 2nd line).
 
That can be stopped, if the downstream projects like this, can be confident
of their patches be present in next (major) release...

 But anyone can suddenly imagine he can do a better job and start an
 independent branch, I don't think it is wise to let that fact influence how
 to setup the process too much.
 
Yeah only by setting an example maybe.

 I'm actually with Silvio on this 
 
 Silvio sets goals but doesn't provide the resources to do so. That is the
 crucial flaw in such rants.

Please don't get us wrong, no one says this has to happen now, immediately or 
OVERNIGHT,
it's more like if ... could some speedup be considered ...? Pretty please ?
That's from me, ordinary user who lives on stable... 

No one asks anyone to overstrain themselves really, and for what effect. 

Only saying, that Linux's approach of the (major) releases happening at 
lightning speed, compared
to what they were doing before, seems to also have effect of more exposure to 
whoever
wants to participate (and other projects seem to be adopting that approach 
too), more patches
and more interested eyeballs. (though probably need for thicker skin sometimes 
as well)

 
 (maybe by altering the criteria, of how much of a change is considered fit 
 for a next major release, 
   /considerably/ down; 
  even if it means, if tracking the features of Delphi compiler is any 
 factor, 
  that for 1 Delphi release, FPC releases 5 or 6 major releases before it 
 catches up)
 
 That is another fundamental flaw, trying to plan something in a project that
 survives on voluntarily work of volunteers.  There is nothing that CAN be
 steered top down in projects like this. 

Well I can understand this... I'm not top-down, I'm the very end of the 
callchain :)

Lukasz

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


Re: [fpc-pascal] lazarus not reachable

2014-04-07 Thread Lukasz Sokol
On 07/04/14 04:17, m...@rpzdesign.com wrote:
 On 4/6/2014 10:54 PM, Ralf Quint wrote:
 On 4/6/2014 7:52 PM, m...@rpzdesign.com
 wrote:
 Well,
 
 I cannot subscribe to the lazarus mailing list and I can not
 enter the forums at forums.lazarus.freepascal.org or
 www.lazarus.freepascal.org because I can not make an http
 connection to either.
 
 Just keep timing out.
 
 FYI for list managers...
 
 Well, you have posted this now several times and several times it
 has been shown that you are the only one who has such problems.
 Could you possibly be bothered to start looking at something that
 could be wrong on YOUR end?:-(
 
 Ralf
 
 

(rearranged, to Marco: pls avoid top-posting... unless you have a good reason) 

 Ralf:
 
 I am very sorry to bother you.
 
 I will not make another request for information on this topic
 
 Each time I started to try to pursue the matter earlier, I got some
 light responses, but never was in a position to fully eliminate the
 problem.
 
 Today, I tried to gather more information using comparative trace
 routes to solve the problem.
 
 Several other users have been very kind to share their trace routes
 failing but are still getting through using HTTP.
 
 If this problem follows me to another internet cafe or public wi-fi,
 I will then try outside of my ISP area or even leave the region to
 run a connection test.
 
 All of my computers and tablets here fail, so is likely some silly
 ISP issue, like C#//.NET developers at my ISP who filter all pascal
 traffic!!!
 
 Thank you everyone for your responses and help.
 
 marco

Hi Marco,

usually a site like http://www.downforeveryoneorjustme.com/ helps  
(short url : http://isup.me )

(btw http://www.downforeveryoneorjustme.com/lazarus.freepascal.org says 
site is up as of 7/4/14 8:40 BST/London time).

-L.

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


Re: [fpc-pascal] Free pascal candidate for project of the month

2014-03-27 Thread Lukasz Sokol
On 26/03/14 20:44, Marco van de Voort wrote:
 
 FYI:
 
 Free Pascal is candidate for SF project of the month april, up against
 strong candidates as subversion for windows (the server, not tortoise) and
 smplayer.
 
 Note that you need a SF login to vote:
 
 https://sourceforge.net/p/potm/discussion/vote/thread/c38203c8/
 
 Marco

VOTE: freepascal 

+1 :)
thanks
-L.



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


Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Lukasz Sokol
On 17/02/14 06:02, Jürgen Hestermann wrote:
 
 Am 2014-02-16 17:16, schrieb Michael Van Canneyt:
 It does exactly that, it says:
 1) No COW
 
 As said already: SetLength *is* a write!
 
 

I'm not of compiler background - but I think you're confusing things here.

To 'write' usually means : changing DATA element(s). That's it. You have a 
sheet of paper of
known size and you write on it/erase/change the text. But the size of the array 
remains the same.

SetLength is /not/ a write in this sense : because you're resizing the paper 
you're
going to write on (e.g. adding another page or cutting it to size)

As far I understood, SetLength is changing the /description/ of the array 
(meta-data?) but not the data itself : 
in this sense, it is not a 'write data' operation.

It does 'write' as in: change parameters - of the array DESCRIPTION area, but 
that area is not ARRAY DATA;
and enlarging/shrinking the memory allocation - but that does not change the 
content of the already
written-to array elements: it may add some blank ones or remove some written-to 
ones, but the rest
remains UNCHANGED, i.e. they (the just-added or remaining-after-removal ones) 
are not being written-to 
by doing SetLength.)

That being said, maybe a mention of what it means to the user of the compiler, 
could actually be beneficial
to overall understanding... like


SetLength:

* Enforces unique refcount (refcount := 1).
* If refcount was more than 1 (i.e. 2 or more pointers to the array existed 
before calling SetLength) 
then it copies array data to new data area, trims or enlarges copied data 
accordingly and returns new pointer to the
resized array.
* otherwise (if refcount was 1) just trims/enlarges the array data area 
accordingly.


Hope this helps,
-L.

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


[fpc-pascal] Linux / timestamps: vdso_[getttimeofday(),clock_gettime(),time(); ] coming our way?

2014-02-03 Thread Lukasz Sokol
Hi Compiler Developers,

foreword: please forgive if this is too low-level etc or if I don't understand
it enough ;)

Since I'm glancing over lkml sometimes, I couldn't help but notice
an announcement by Stefani Seibold, that a fast, reliable userspace timestamp
function(s) are on the process to land in the Linux kernel.

The mechanism is said to be using VDSO (http://en.wikipedia.org/wiki/VDSO sorry
for wikipedia link... so lame I had to look it up ;) )

This being targeted to the 'development' kernel(s) so far, may be a bit
off the charts, (but then the announcement says x86_64 has it already in glibc)
any chances FPC could make use of it when it actually lands in user-visible 
configurations?

See the announcement here 

http://news.gmane.org/find-root.php?message_id=1391413721%2d17148%2d1%2dgit%2dsend%2demail%2dstefani%40seibold.net

Curiously,
-L.

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


Re: [fpc-pascal] best method: multiple three state options in a decision tree

2014-01-28 Thread Lukasz Sokol
Hello Jürgen,



On 27/01/14 17:50, Jürgen Hestermann wrote:
[...] 
 
 I recently had a similar problem and solved it this way:
 With
 
 ---
 type FlagType  = (FlagA,
   FlagB,
   FlagC,
   FlagD,
   FlagE,
   FlagF);
  FlagSetType = set of FlagType;
 var  FlagSet : FlagSetType;
 ---
 
 I get a compact bit array (a set) where I can give each bit an individual 
 name.
 Then these sets
 
 ---
 [FlagA,FlagB,FlagC,FlagD,FlagE,FlagF]
 [FlagA,  FlagC,FlagD,FlagE,FlagF]
 [FlagA,FlagB,FlagC,FlagD,FlagE,FlagF]
 [FlagA,FlagD,FlagE,FlagF]
 [FlagA,FlagB,FlagE,FlagF]
 [FlagA,FlagB,FlagC,FlagD,FlagE  ]
 ---
 
 select one number (which it internaly is) and
 
 ---
 byte([FlagA,FlagB,FlagC,FlagD,FlagE,FlagF])
 byte([FlagA,  FlagC,FlagD,FlagE,FlagF])
 byte([FlagA,FlagB,FlagC,FlagD,FlagE,FlagF])
 byte([FlagA,FlagD,FlagE,FlagF])
 byte([FlagA,FlagB,FlagE,FlagF])
 byte([FlagA,FlagB,FlagC,FlagD,FlagE  ])
 ---

I thought about this too, but this means waldo's use case would be

type TOptions = [FlagAMin, FlagAMinMax, FlagAMax, ... FlagFMin, FlagFMinMax, 
FlagFMax] 

which would allow a nice usage of

if FlagAMin in Options then ...

but which he'd have to marshall (to disallow FlagA* set more than once) same 
way as he does now, bit by bit,
only more verbose... whereas the 'array of set' would be more readable [IMHO] 
and did that 'automatically'.

Since we need a way to group the flag values so that one flagset option can be 
one of 3 states 
[4 still be a better choice, being a power of 2 and uses same number of bits 
anyway ] 
and distinctly read/set the value of an option, my array idea was (I think) 
closest...

I also thought of

type TFlag = [FlagNone, FlagMin, FlagMinMax, FlagMax];

type TOptions = packed record
   FlagA : TFlag;
   FlagB : TFlag;
   ...
end;

but that is more awkward and ultimately the array is easier to expand.or to 
turn to dynamic.

A nice touch would be if

TFlag = [FlagNone, FlagMin, FlagMinMax, FlagMax];

TFlags = set of TFlag;

TOptions = set of TFlags; // which would still pack into available 'set' type 
of variable, 
// allowing constructs like byte(Options) to be used

but how would we then access individual options  in TOptions? AFAIK the above 
is impossible anyway;

Another I thought of was

type
TFlag = [FlagMin, FlagMinMax, FlagMax];

TFlagA = TFlag; TFlagB = TFlag; ... TFlagF = TFlag;

TOptions = [FlagA : TFlagA, ... FlagF : TFlagF]; 
// which ultimately is no different than the array approach
// but still less flexible
// and probaby impossible the way I wrote it above too.

Other ideas included having the flags use bitwise constants so that 
pushing/pulling it out of the set
would ensure the state of any Option be always of distinct choice, best if not 
having to think about clearing the remnants of other states by hand... but I 
failed to materialize this vision :)

The only way I could visualize was to have the distinct Options values declared 
as Flags shifted two bits to the left each,
and then yes using bitwise AND; this however limits number of options to 
bitsizeof(Byte) div 2 = 4 ... or bitsize(Word) div 2 = 8.
and requiring bitwise AND masks and then shift, for use with the rest of the 
Options value to read the value... messy.

Whereas with array of set this all happens beyond our influence...

All in all, IMHO and YMMV, again ;)

-L
 
 can be used to convert them to real (integer) numbers in a case statement:
 
 ---
 case byte(FlagSet) of
byte([FlagA,FlagB,FlagC,FlagD,FlagE,FlagF]) : begin .. end;
byte([FlagA,  FlagC,FlagD,FlagE,FlagF]) : begin .. end;
byte([FlagA,FlagB,FlagC,FlagD,FlagE,FlagF]) : begin .. end;
byte([FlagA,FlagD,FlagE,FlagF]) : begin .. end;
byte([FlagA,FlagB,FlagE,FlagF]) : begin .. end;
byte([FlagA,FlagB,FlagC,FlagD,FlagE  ]) : begin .. end;
end; // of case
 ---
 
 and still I can use the set as a usual set:
 
 ---
 include(FlagSet,FlagD);
 ...
 if FlagA in Flagset then..
 ...
 etc.
 ---
 
 I even use an array which is indexed with the set variable:
 
 ---
 type FlagSetArrayType = array[0..(1 shl (ord(High(FlagSetType))+1))-1] of 
 any_other_type; // 0..2^n-1
 ---
 
 which holds information for all 2^n possible flag combination in the set.
 Then I can use the set variable to index the array like this:
 
 ---
 var FlagSetArray = FlagSetArrayType;
 ...
 
 any_other_type_variable := FlagSetArray[ 
 byte([FlagA,FlagB,FlagC,FlagD,FlagE,FlagF])   ];
 

Re: [fpc-pascal] best method: multiple three state options in a decision tree

2014-01-27 Thread Lukasz Sokol
On 24/01/14 16:20, waldo kitty wrote:
 On 1/23/2014 5:01 AM, Lukasz Sokol wrote:
 
 Maybe Something like: (but this is with type TOptionMinMax =
 [mmNone, mmMin,mmMinMax, mmMax])
 
 i wanted to thank you, lukasz, for your input... it has made me take
 another look while rewriting to implement your ideas...
 
 during this process i had an epiphany... that being that i don't need
 three individual states for each option since one of those states is
 ANDing two of those states... since i'm ANDing all valid
 possibilities anyway, this will free up 5 'bits' or 'scores' leaving
 room for more options if needed in the future... it will also lessen
 the complexity of the CASE decision tree but not by very much...
 
 with the above epiphany and some other information i have acquired,
 i'm now in the process of rewriting the app... i suspect it will take
 me a day or two to get to the point i was at previously with the
 operational and in-use code but i still wanted to say thanks to you
 and others who provided ideas, insights and information ;) :)
 

Glad to hear that not all I thought of is a brain fart ;)

However I'm still curious : why use bits directly, when you can have a 
set/'enum' of 
possible choice(s), guaranteed to be distinct - so you can't physically set 
OptionA twice, by definition,
 and then make the Options be an array of the options? 
Yes it may be using Sizeof(set) x num options (1 byte per option?) but then 
it's not for you 
to worry any more about the bits - the compiler will care for that and you can 
go rethink the logic ;)
and also readability and maintainability +100 ;) 
But IMHO of course and YMMV ;)

Kind Regards,
-L. ;)

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


Re: [fpc-pascal] best method: multiple three state options in a decision tree

2014-01-23 Thread Lukasz Sokol
On 22/01/14 21:23, waldo kitty wrote:
[...] 
 - associate the procedures (their pointers) to jump to with the
 valid bit masks in a new data type (- do you REALLY have that many
 procedures ? Or are they somewhat repeating themselves ?)
 
 it will be only two procedures IF i can do it like that... it should
 be easier to use one CASE procedure of the existing ~8000 lines for
 both (future) input selection of matching data records and for
 (current) output filtering of matching data records...
 
 so what i was actually asking is if using a pointer is the proper
 item for passing the procedure to use and is @procA how i would
 specify that in the call to the procedure...
 
 - then just walk the array of [bit mask, proc pointer] records and
 jump to pointers supplied if matching?
 
 No ifs, no buts, treat the Options as a bitmask if such is its
 purpose?
 
 Just a thought,
 
 i really am trying to visualize your suggested methods ;)
 

Maybe Something like: (but this is with type TOptionMinMax = [mmNone, 
mmMin,mmMinMax, mmMax])


//then 
type
TOptionsArray = array[0..4] of TOptionMinMax;

var 
OptionsArray : TOptionsArray;

//then you process all the options and do some kind of score to them :


function JumpTo(AOptionsArray : TOptionsArray): TProcedure;
var Score : integer;

begin
for i := 0 to 4 do // walk the array one by one
  begin
case AOptionsArray[i].Option of
  mmMin : ;   // 
  mmMinMax : ;// here gather the 'score' of the particular set of options
  mmMax : ;   // depending on 'i' and these 4 cases - if there is a 
well-defined formula detecting this
  else// 
end; // case
  end; // for

//then the actual detection of score to actual procedures

if Score  something1 then Result := AddressOf(Procedure1); end;  // 
pseudo-code ;)
if Score = someting1 and Score  something2 then ... end;
...
...

end;

// converting the above to dynamic array of Options :

type
TOptionMinMax = [mmMin, mmMinMax, mmMax]; 

TOption = record
  OptionIndex : integer;
  OptionMinMax : TOptionMinMax;
end;

TOptionsArray = array of TOption;

function JumpTo(AOptionsArray : TOptionsArray): TProcedure;
var Score : integer;

begin
for i := 0 to SizeOf(AOptionsArray)-1 do
  begin
case AOptionsArray[i].Option of
  mmMin : ;   // 
  mmMinMax : ;// here gather the 'score' of the particular set of options
  mmMax : ;   // depending on 'OptionIndex'(!) and these 3 cases - if there 
is a well-defined formula detecting this
  // no mmNone because it's only to say the option is not in 
the set
end; // case
  end; // for

//then the actual detection of score to procedure(s)

if Score  something1 then Result := AddressOf(Procedure1); end;  // 
pseudo-code ;)
if Score = someting1 and Score  something2 then ... end;
...
...

end;

// score detection to procedures could be also automated:

type TJumpToScoreProcedure = record
   MinScore : integer;
   MaxScore : integer;
   JumpTo : TProcedure;
end;

// declare the above statically / or dynamically somewhere in an array:

const JumpToArray = [(MinScore : 10; MaxScore : 20 ; JumpTo : @Procedure1), ... 
];

// and the actual detection in the JumpTo function above ^^^

for j  := 0 to SizeOf(JumpToArray)-1 do
  if (Score  JumpToArray[j].MinScore) and (Score  JumpToArray.MaxScore) then 
Result := JumpToArray[j].JumpTo;



// usage in both cases would be:

@Procedure := JumpTo(OptionsArray);

if Assigned(Procedure) then Procedure(); // in case we did not get a valid 
pointer from all that or
there was an error

Is this what you meant ? 

-L.



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


Re: [fpc-pascal] best method: multiple three state options in a decision tree

2014-01-22 Thread Lukasz Sokol
On 21/01/14 18:42, waldo kitty wrote:
 On 1/21/2014 10:21 AM, Mattias Gaertner wrote:
 On Tue, 21 Jan 2014 09:51:38 -0500
 waldo kitty wkitt...@windstream.net wrote:

 On 1/18/2014 7:40 PM, waldo kitty wrote:

 what is the best method of coding a decision tree with options that have 
 three
 states and all options are additive?

 clarification: i have a situation with 5 (at this time) options and all 5 
 are
 three state... each option can be paired with all other options' states 
 but may
 NOT be paired with its own other states...
 [...]

 no one has any ideas or thoughts on this?

 Maybe I don't understand the question.
 
 that's quite possible... it took me a while to write it the way i did
 after starting over numerous times... i may have also used the wrong
 terms for what i was trying to describe as well as not giving enough
 examples but the example list was getting too large at that point
 anyway ;) 
 The 5 options with each 3 states sounds like an array[1..5] of TRedGreenBlue.

^This
 
 a lot of stuff i googled up related to 3states came up with
 similar... to me that reads as to be used for graphics and this is a
 console app with no graphics involved... i'm only using the bits to
 denote the combinations available... they select which IF statement
 is used in the actual filter code described below... 
 originally i had thought of using an array but i didn't know the size
 of it and each grouping varies with the number of options... 
 What do you mean with additive
 
 logical AND with some combinations being invalid...
 
 eg:
 optionA:min/max {solitary}
 optionB:max only AND optionE:min only {two ANDed together}
 optionA:min only AND optionB:min/max AND optionC:max only {three ANDed 
 together}
 
 optionA:min/max AND optionA:min only {invalid}
 optionA:min/max AND optionA:max only {invalid}
 optionA:min only AND optionA:max only {invalid}
 
and ^this
[...]
 the current idea is to use a bit for each state and then use a case
 statement for the decision tree (as shown above) so as to simply
 walk thru the integers that the bit patterns make for the valid
 combinations... 

^and this...
looks like a (good?) use for a dynamic array of TMinMaxState = [mmNone, mmMin, 
mmMinMax, mmMax];
(then var Options = array[static or dynamic] of TMinMaxState;)

This assumes options have a fixed position in the array however... but the 
bitwise code was 
assuming this anyway.

And yes, 4 states - one of them being mmNone - for the case when you don't want 
to use certain option.

If there is a lot of options, but not always consecutive - so there would be a 
lot more of mmNone's
than significant states (IOW the data is sparse) - maybe do

TOption = record
  Index : [whatever type would suffice here];
  State : TMinMaxState; // [which could then be 3 state not 4]
end;

and use a dynamic array to hold the TOption(s).

Excuse my lameness please :) as I am not a programmer by trade.

-L.


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


Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()

2014-01-13 Thread Lukasz Sokol
Hi,

'scue me if I did not catch something, but

On 13/01/14 12:13, Fred van Stappen wrote:
[...]

  procedure InitLib(LibFile : PAnsiChar);
  begin
  LibHandle:=DynLibs.LoadLibrary(libfilename);
if LibHandle  DynLibs.NilHandle then
 
  Pointer(soundtouch_createInstance):= 
  DynLibs.GetProcedureAddress(LibHandle, 
  PAnsiChar('soundtouch_createInstance'));
 
/// why not just :

@soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 
PAnsiChar('soundtouch_createInstance')); 

(or without the PAnsiChar cast as Michael said:)

@soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 
'soundtouch_createInstance'); 

?


 Remove the typecast PansiChar()
 
 Michael.
[...]
  
 What is the value of  Pointer(soundtouch_createInstance) after the above 
 statement ? Is it nil ?
  
 Michael.
 
 Thanks for answer Michael.
 
 Hum, how can i get the value of pointer if the application crash when i do :
 
  FHandle := soundtouch_createInstance();  
 
 Maybe, i dont understood your question...
 

if Assigned(soundtouch_createInstance) then ShowMessage('Got good pointer for 
soundtouch_createInstance')
else ShowMessage('soundtouch_createInstance not assigned);

placed directly after the GetProcedureAddress call ?


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


Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()

2014-01-13 Thread Lukasz Sokol
On 13/01/14 13:36, Fred van Stappen wrote:
[...] 
 Hello Lucaz
 
 /// why not just :

 @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 
 PAnsiChar('soundtouch_createInstance'));

 
 Get that error :
 
 libSoundTouch.pas(56,5) Error: Can't assign values to an address
 

This (@syntax) is in (OBJ)FPC mode, your example is Delphi mode.



http://wiki.freepascal.org/Lazarus/FPC_Libraries#Loadlibrary_-_dynamically_loading_a_dynamic_library

http://forum.lazarus.freepascal.org/index.php?topic=1148.0

OK I stand corrected, re. the pointer() cast... 

but then why not declare in a public header for this wrapper:
type
  TSoundtouchCreateInstanceProc = procedure;

then
soundtouch_createinstance := 
TSoundtouchCreateInstanceProc(DynLibs.GetProcedureAddress(...));

(nb. delphi mode)

?

-L.

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


[fpc-pascal] Re: how to simplify try try except end finally end?

2013-12-27 Thread Lukasz Sokol
On 26/12/13 12:13, Reinier Olislagers wrote:
 On 26/12/2013 13:09, Dennis Poon wrote:
 It seems possible in Java and C# but not in FPC.
 Is there a way to combine them like
 
 No.
 Search the archives for proposals for syntax like this that didn't lead
 to anything.
 

It did lead exactly to Sven liking it ;) and (I think) to submitting a feat 
request.

IOW, I suppose patches are welcome (but I'm not competent enough to do that)

-L.

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


[fpc-pascal] Re: cannot read /sys/class/net/eth1/address even as root user on linux

2013-12-06 Thread Lukasz Sokol
On 05/12/13 14:42, Dennis Poon wrote:
 
 While your method should work if that file actually exists, you
 probably want to use libudev for enumerating and getting device
 information from sysfs.  libudev will also enable you to get
 hotplug notification.
 
 
 For your your reply. The fact is: 1)  my linux distro starts with
 eth1 not eth0. Strange. I know. 2) my question was, why simply 'cat'
 works but I cannot read it from fpc usign Tfilestream or readlin(F,
 S);
 
 Since I don't have time to invest in a portable solution, I am happy
 already if it works on my particular xubuntu distro.
 
 Dennis

Try installing strace and use it :

 strace your executable name 

from command line/terminal ?

-L.

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


[fpc-pascal] Re: identifier not found case probelm

2013-11-12 Thread Lukasz Sokol
On 12/11/13 16:27, leledumbo wrote:
 I have a feeling this 'returns' may be a keyword...
 
 No, it is not, I believe. Reserved words are listed in the docs.
 

Yeah, I checked too, 'returns' isn't a keyword.

-ENOCRYSTALBALL but /maybe/ the 'returns' is declared 'under' the code in 
question
so it's not known prior to usage

-L.


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


[fpc-pascal] Re: identifier not found case probelm

2013-11-11 Thread Lukasz Sokol
On 10/11/13 10:54, rambo waz here wrote:
 at the moment i have a case where each choice leads off to a procedure. ..
 looks like this
 repeat
 writeln('Main Menu');
 writeln('1. New Customer Info');
 writeln('2. Withdrawal');
 writeln('3. Returns');
 writeln('4. Money owed by customer');
 writeln('5. Quit the Program');
 readln(menu_choice);
 if menu_choice in [1..5]
 then case menu_choice of 1: new_customer;
  2: withdraw;
  3: returns;
  4: money_owed;
  5: writeln('stop')
  end
 else writeln('1..5!)
 until choice = 5   
 
 but when i try to run it it comes up with an error saying identifier not
 found and highlights each of the case choices .. i.e. 3: returns;
 .. any help ? :( :( :(
 
 

Maybe try renaming the Returns procedure (e.g. to CashReturns or CreditReturns)
I have a feeling this 'returns' may be a keyword...

-L.


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


[fpc-pascal] Re: RFD: CardDAV support library for FreePascal, call for ideas

2013-09-26 Thread Lukasz Sokol
On 26/09/13 01:29, Daniel Gaspary wrote:
 On Wed, Sep 25, 2013 at 12:22 PM, Lukasz Sokol el.es...@gmail.com wrote:
 CalDAV itself is used on the CRM I use, but I've no demand for interacting
 with it. Yet.*
 
 I have just taken a look at the RFC* and it seems simple to implement.
 
 I don't need CardDav right now, but I believe I will need it soon.
 
 Can you take (and share) CardDav samples needed on this CRM? They
 could be useful.
 

So far, I cp the examples included in the RFC (OPTIONS, 
REPORT/CARDDAV:addressbook-multiget)
pasting into my program as plain text and it sure enough works;
maybe not a briliant way to do things, but it does (in the sense that it 
produces output
I expect).

Due to quite a short time I spent on it so far, I haven't delved much deeper 
into
using the DOM.pas (or indeed any other abstract XML class) directly -
all it does for me so far, is validation of XML and mid-point to a more visual
representation of it into TTreeNodes, which ultimately isn't needed but helps
me imagine what's going on.

 
 * http://tools.ietf.org/html/rfc6352#page-4

(I'll continue in other replies to MvC in this thread)

Thanks,
-Lukasz

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


[fpc-pascal] Re: RFD: CardDAV support library for FreePascal, call for ideas

2013-09-26 Thread Lukasz Sokol
On 25/09/13 20:31, Michael Van Canneyt wrote:
 
 
 On Wed, 25 Sep 2013, Lukasz Sokol wrote:
 
 Hello,
 
[...]
 But I'd like to know, if there is interest in making it 'more
 sentient', e.g. as a TDataSource/TDataSet descendant directly
 talking to (reading, at first) DOM.pas's TXMLDocument/TDOMDocument,
 then to a THTMLSend or any such class of your liking?
 
 I do not think that a TDataset descendent is needed. A simple
 collection based class will do just fine, and a class to handle
 transport. I have one for WebDAV, and CardDav really is not so much
 different.

So far fiddling with plain text queries, I'm consistently getting
contents of vcards that I expect to get [through REPORT method]

I think I should focus on more 'low hanging fruit' for now : building
the xml CardDAV query using the TXMLDocument* class, as I pass it to 
Synapse's THTMLSend.Document later anyway, and handling of what's
received through the same TXMLDocument*.
 
(* out of whichever *DOM.pas comes to use eventually)

When that's done, we'll think of higher levels
(one immediately comes to mind - vCard handling.)

 
 I also do not see why you would need alterations to DOM.pas, both
 WebDav and CardDav use plain and simple XML.

I merely based my assumption on DOM.pas comment stating level3 is partially 
implemented...
should have worded it differently:

It remains to be seen whether any DOM Level 3 additions will be needed into
DOM.pas since it states it's Partially Implemented


 
 BTW. The RFC is 6352 instead of 6532.
 
yeah. sorry 'bout that too :)

-L.

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


[fpc-pascal] Re: RFD: CardDAV support library for FreePascal, call for ideas

2013-09-26 Thread Lukasz Sokol
On 26/09/13 11:00, Michael Van Canneyt wrote:
 
 
 On Thu, 26 Sep 2013, Lukasz Sokol wrote:
 
 I also do not see why you would need alterations to DOM.pas,
 both WebDav and CardDav use plain and simple XML.
 
 I merely based my assumption on DOM.pas comment stating level3 is
 partially implemented... should have worded it differently:
 
 It remains to be seen whether any DOM Level 3 additions will be
 needed into DOM.pas since it states it's Partially Implemented
 
 I understood you correctly.
 
 DOM is an implementation specification. Not an XML specification.
 
 DOM level 3 has nothing to do with the ability to process XML. DOM
 level 2 will just as well parse any valid XML.
 
 The only thing DOM level 3 will probably give you is perhaps some
 extra methods/properties to make life easier.
 
 Just tring to point out that you should be fine with the dom unit as
 it is, before you go chasing ghosts and spend time on things that are
 not essential :)
 
 Michael.

Noted, thanks - so far haven't got as far as using dom.pas directly,
yet. But I wanted to experiment with open text xml with different queries first,
then translate into direct dom.pas usage.

Low hanging fruit ;) and time constraints.

-L.


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


[fpc-pascal] RFD: CardDAV support library for FreePascal, call for ideas

2013-09-25 Thread Lukasz Sokol
Hello,

since I have not found anything on CardDAV related/written in/for 
FreePascal/Lazarus,
(haven't googled with Delphi keyword thou)

I'd like to send out some smoke signals, asking which way would the
support for this kind of interaction (dare not call it a protocol)
would be best fitting into FreePascal/Lazarus world.

CardDAV itself is an extension of WebDAV and itself has its own RFC (RFC6532).

I myself am trying to write a client connecting via CardDAV to a
compatible server (built into my CRM, eGroupware) to request search and read 
addressbook entries.

(it was the developers of the CRM in question indicated to me that XMLRPC is 
dead and support
for it will be removed when they get a chance - that's why I'm doing this.)

So far I got as far as copy/pasting example XML from the RFC and
got a valid response from server, using THTTPSend from Synapse.
http://wiki.freepascal.org/XML_Tutorial (and particularly the second XML2Tree 
procedure from
http://wiki.freepascal.org/XML_Tutorial#Populating_a_TreeView_with_XML, with 
some mod of mine
to not pass a TTreeView but a TTreeNodes object into it instead) came in handy 
to understand 
the structure of it.

There are certain advantages of CardDAV over XMLRPC, which this post is too 
short to contain ;) 

I intend to keep it very simple at first, as it's enough for my purpose, to the 
point that the XML
elements+attributes would be coded just as string concatenating operations and 
validated using 
TXMLDocument from dom.pas.
Seems like the more complicated elements of DOM level 3 will need DOM.pas 
modifications too.

But I'd like to know, if there is interest in making it 'more sentient', e.g. as
a TDataSource/TDataSet descendant directly talking to (reading, at first) 
DOM.pas's 
TXMLDocument/TDOMDocument, then to a THTMLSend or any such class of your liking?

Please let me know your thoughts :)

Kind Regards
Lukasz

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


[fpc-pascal] Re: RFD: CardDAV support library for FreePascal, call for ideas

2013-09-25 Thread Lukasz Sokol
On 25/09/13 14:56, Daniel Gaspary wrote:
 On Wed, Sep 25, 2013 at 8:03 AM, Lukasz Sokol el.es...@gmail.com wrote:
 Seems like the more complicated elements of DOM level 3 will need DOM.pas 
 modifications too.
 
 What kind of modification ?
 
Uh, you got me - I don't know as I haven't started yet...
I was merely referring to what dom.pas has at the top of itself:

DOM Level 3  -  Partially implemented 

so I should have phrased it differently :

It remains to be seen whether any DOM Level 3 additions will be needed into
DOM.pas since it states it's Partially Implemented


 I have sent this patch [1] to allow create custom descendants of
 TDomElement. You can check whether this could be useful to you.
 

Noted, I for now am very very early in this so I can't tell.

 I believe at least two more methods[2] need to be changed.
 
 The patch is meant to modify dom.pas, but maybe I should have made it
 to laz2_dom, as it seems to have more attention these days(being
 update to UTF8 I Believe).
(mental note: check las2_dom.)

 
 By the way, feedback (is a viable suggestion, no, why..?) on this
 subject would be appreciated.

Of course I will give feedback when (and if) I get any.

For now, I was merely asking, what direction the development should take,
and whether it's a good idea to make it into a Data Access palette component 
like 
T*DataSet, or is it 'overkill'.

 
 
 [1] http://bugs.freepascal.org/view.php?id=24860
 [2] CreateElement and CreateElementBuf

Thanks for your reply,

Kind Regards,
Lukasz

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


[fpc-pascal] Re: RFD: CardDAV support library for FreePascal, call for ideas

2013-09-25 Thread Lukasz Sokol
On 25/09/13 16:00, Reinier Olislagers wrote:
 On 25/09/2013 16:45, Lukasz Sokol wrote:
 On 25/09/13 14:56, Daniel Gaspary wrote:
 On Wed, Sep 25, 2013 at 8:03 AM, Lukasz Sokol
 el.es.cr-re5jqeeqqe8avxtiumw...@public.gmane.org
 wrote:
 For now, I was merely asking, what direction the development should
 take, and whether it's a good idea to make it into a Data Access
 palette component like T*DataSet, or is it 'overkill'.
 
 Well, it would be nice to have a dataset encapsulation but perhaps
 your time would be better spent on CalDAV support (grins, ducks 
 runs...) ;)
 

Well, let's not say 'hop' before landing on the other side of the ditch ;)

CalDAV itself is used on the CRM I use, but I've no demand for interacting
with it. Yet.*

From fiddling with open coded HTTP Requests, I'm so far getting open coded 
vCard's
as string ;) 

(*and probably applications like Sunbird/Lightning are better for it anyway*)

-L.

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


[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-24 Thread Lukasz Sokol
On 23/09/13 17:18, Bart wrote:
 On 9/23/13, Lukasz Sokol el.es...@gmail.com wrote:
 
 function TryRomanToInt(AInput:String; out AResult: integer):boolean;
 var i, Len, N, Np1 : integer;
 [snip]


 if N = Np1 then AResult := AResult + N
 else AResult := AResult - N;

   end;
 else // i = Len-1 = last char we just add (consider : MCM : add 1000,
 
 Compiler doesn't like the else here. I removed the ; after the end 1 line 
 above.
I said below it's only mind-compiled ;)

 
 sub 100, add 1000 = 1900)
  begin
AResult := AResult + N;
  end;
   end; // for
   // if the above, after all characters are through, has resulted in 0 or
 less,
   // we invalidate everything at the end (consider : CMLM, IIIM )

   Result := AResult  0;
   if not Result then AResult := 0;
 end;

 (only mind-compiled ;) tests welcome ;) )

 
 It produces odd output though:
 
 C:\Users\Bart\LazarusProjecten\ConsoleProjectentest
 Enter Roman numeral: LL  //should be illegal
 TryRomanToInt('LL') - 50
 StrUtils.RomanToInt('LL') = 100
Oh I see the loop needs to run from 0 to Len-1 ? it missed the last (or 
first) char

 
 Enter Roman numeral: MM
 TryRomanToInt('MM') - 1050  //obviously should be 2000
But this looks like you're adding the results? Or are you reusing the
same variable ? In that case stick AResult := 0 at the top of the function 
please

 StrUtils.RomanToInt('MM') = 2000
 
 Enter Roman numeral: II
 TryRomanToInt('II') - 1051  // nice one!  
Yeah totally added to former Aresult, and missed last char ...

 StrUtils.RomanToInt('II') = 2
 
 So, it's a little bit flawed.

:)

function TryRomanToInt(AInput:String; out AResult: integer):boolean;
var i, Len, N, Np1 : integer;

  function TryRomanCharToInt(AIn: Char; out AOut: integer): boolean;
  begin
case AIn of
  'M' : AOut := 1000;
  'D' : AOut := 500;
  'C' : AOut := 100;
  'L' : AOut := 50;
  'X' : AOut := 10;
  'V' : AOut := 5;
  'I' : AOut := 1;
else
  AOut := 0;
end;
Result := (AOut  0);
  end;

begin
  // if it looks like shameless cp, it's because it is ;)
  Result := False;
  AResult := 0; //  here you've reused the variable passed to AResult 
somewhere
  AInput := UpperCase(AInput);  //don't use AnsiUpperCase please
  Len := Length(AInput);
  if (Len = 0) then Exit;
  // 
  i := 1;
  for i := 0 to Len-1 do // which char am I actually missing here??? 
  begin
if not TryRomanCharToInt(AInput[i], N) then
begin
  AResult := -1; // invalidate everything
  exit;
// writeln('Not a valid roman numeral at position ',i);
end;

if (i  Len-1) then 
  begin 
if not TryRomanCharToInt(AInput[i+1], Np1) then
begin
  AResult := -1; // invalidate everithing
  exit;
// writeln('Not a valid roman numeral at position ',i+1);
end;
 
// according to wikipedia, .
if not (((N = 100) and (Np1  100)) or  // C can be placed before L or M
((N = 10) and (Np1  10) and (Np1 = 100)) or // X can be 
placed before L or C
((N = 1) and (Np1  1) and (Np1 = 50)))  // I can be placed 
before V and X  here too
then
  begin
AResult := -1; // invalidate everithing: catches MDCLXVIVXLDM
exit;
// writeln('Not a valid roman numeral combination at position ',i, 
' and ',i+1);
  end;
  

if N = Np1 then AResult := AResult + N
else AResult := AResult - N;

  end // i  Len-1, you're right about the ; 
else // i = Len-1 = last char we just add (consider : MCM : add 1000, sub 
100, add 1000 = 1900)
 begin // alternatively this should exit the loop maybe on the N-1th 
character 
   AResult := AResult + N;
 end;
  end; // for
  // if the above, after all characters are through, has resulted in 0 or less,
  // we invalidate everything at the end (consider : CMLM, IIIM )
  
  Result := AResult  0;
  if not Result then AResult := 0;
end;


 
 Anyhow, let's not focus upon what the new code should be.
 The question was: is current behaviour (accepting IIMIIC etc.) a bug or not.
 
 Bart
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal
 


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


[fpc-pascal] Re: StrUtils.RomanToInt oddities

2013-09-23 Thread Lukasz Sokol
On 20/09/13 19:49, Bart wrote:
 On 9/20/13, Reinier Olislagers reinierolislag...@gmail.com wrote:
 
 The question however becomes what is the
 algorithm for deciding invalid characters which IMO will become a mess
 very quickly. Much better to just consider the entire input as invalid.

 
 Here's my implementation:

Here is how I would write it ;)

function TryRomanToInt(AInput:String; out AResult: integer):boolean;
var i, Len, N, Np1 : integer;

  function TryRomanCharToInt(AIn: Char; out AOut: integer): boolean;
  begin
case AIn of
  'M' : AOut := 1000;
  'D' : AOut := 500;
  'C' : AOut := 100;
  'L' : AOut := 50;
  'X' : AOut := 10;
  'V' : AOut := 5;
  'I' : AOut := 1;
else
  AOut := 0;
end;
Result := (AOut  0);
  end;

begin
  // if it looks like shameless cp, it's because it is ;)
  Result := False;
  AInput := UpperCase(AInput);  //don't use AnsiUpperCase please
  Len := Length(AInput);
  if (Len = 0) then Exit;
  // 
  i := 1;
  for i := 1 to Len-1 do 
  begin
if not TryRomanCharToInt(AInput[i], N) then
begin
  AResult := -1; // invalidate everything
  exit;
// writeln('Not a valid roman numeral at position ',i);
end;

if (i  Len -1) then 
  begin 
if not TryRomanCharToInt(AInput[i+1], Np1) then
begin
  AResult := -1; // invalidate everithing
  exit;
// writeln('Not a valid roman numeral at position ',i+1);
end;
 
// according to wikipedia, wonder if these are hard or soft rules 
thou...
if not (((N = 100) and (Np1  100)) or  // C can be placed before L or M
((N = 10) and (Np1  10) and (Np1 = 100)) or // X can be 
placed before L or C
((N = 1) and (Np1  1) and (Np1 = 10)))  // I can be placed 
before V and X
then
  begin
AResult := -1; // invalidate everithing: catches MDCLXVIVXLDM
exit;
// writeln('Not a valid roman numeral combination at position ',i, 
' and ',i+1);
  end;
  

if N = Np1 then AResult := AResult + N
else AResult := AResult - N;

  end;
else // i = Len-1 = last char we just add (consider : MCM : add 1000, sub 
100, add 1000 = 1900)
 begin
   AResult := AResult + N;
 end;
  end; // for
  // if the above, after all characters are through, has resulted in 0 or less,
  // we invalidate everything at the end (consider : CMLM, IIIM )
  
  Result := AResult  0;
  if not Result then AResult := 0;
end;

(only mind-compiled ;) tests welcome ;) )

-L

 
 program test;
 
 {$mode objfpc}
 {$H+}
 
 uses
   SysUtils, StrUtils;
 
 
 function TryRomanToInt(S: String; out N: Integer): Boolean;
 var
   i, Len: Integer;
   Terminated: Boolean;
 begin
   Result := (False);
   S := UpperCase(S);  //don't use AnsiUpperCase please
   Len := Length(S);
   if (Len = 0) then Exit;
   i := 1;
   N := 0;
   Terminated := False;
   //leading M's
   while (i = Len) and (S[i] = 'M') do
   begin
 //writeln('TryRomanToInt: Found 1000');
 Inc(i);
 N := N + 1000;
   end;
   //then CM or or CD or D or (C, CC, CCC, )
   if (i = Len) and (S[i] = 'D') then
   begin
 //writeln('TryRomanToInt: Found 500');
 Inc(i);
 N := N + 500;
   end
   else if (i + 1 = Len) and (S[i] = 'C') then
   begin
 if (S[i+1] = 'M') then
 begin
   //writeln('TryRomanToInt: Found 900');
   Inc(i,2);
   N := N + 900;
 end
 else if (S[i+1] = 'D') then
 begin
   //writeln('TryRomanToInt: Found 400');
   Inc(i,2);
   N := N + 400;
 end;
   end ;
   //next max 4 C's
   if (i = Len) and (S[i] = 'C') then
   begin
 //find max 4 C's
 //writeln('TryRomanToInt: Found 100');
 Inc(i);
 N := N + 100;
 if (i = Len) and (S[i] = 'C') then
 begin
   //writeln('TryRomanToInt: Found 100');
   Inc(i);
   N := N + 100;
 end;
 if (i = Len) and (S[i] = 'C') then
 begin
   //writeln('TryRomanToInt: Found 100');
   Inc(i);
   N := N + 100;
 end;
 if (i = Len) and (S[i] = 'C') then
 begin
   //writeln('TryRomanToInt: Found 100');
   Inc(i);
   N := N + 100;
 end;
   end;
 
   //then XC or XL
   if (i + 1 = Len) and (S[i] = 'X') then
   begin
 if (S[i+1] = 'C') then
 begin
   //writeln('TryRomanToInt: Found 90');
   Inc(i,2);
   N := N + 90;
 end
 else if  (S[i+1] = 'L') then
 begin
   //writeln('TryRomanToInt: Found 40');
   Inc(i,2);
   N := N + 40;
 end;
   end;
 
   //then L
   if (i = Len) and (S[i] = 'L') then
   begin
 //writeln('TryRomanToInt: Found 50');
 Inc(i);
 N := N + 50;
   end;
 
   //then (X, xx, xxx, )
   if (i = Len) and (S[i] = 'X') then
   begin
 //find max 4 X's
 //writeln('TryRomanToInt: Found 10');
 Inc(i);
 N := N + 10;
 if (i = Len) and (S[i] = 'X') then
 begin
   //writeln('TryRomanToInt: Found 10');
   

[fpc-pascal] Re: build a compiler for GO32v2 under Windows 8 (or 7)

2013-09-19 Thread Lukasz Sokol
On 18/09/13 17:48, Philippe wrote:
 (first time I am using the mail list ... I may do it wrong!)
 
 
 
 I have a quite big program (now with more than 200.000 lines), first
 build with TP7. For example it accesses CGA memory through absolute
 address ...
 
 Years ago I moved to FPC. And it compiled ok under Windows 98 then
 under XP.
 
 Now with with a new PC running Windows 8 ... the compiler bugs. It
 works fine with small program  but not with one which executable
 about 1.5 Mb large (which is my case, I did not checked till which
 size it works!).
 
 My program should run in prompt command window of any MS Windows
 version (compiling on XP machine, the executable runs fine on MS
 Windows 8 machine)
 
 The bug may not be fixed soon ... version of the compiler for
 DOS/GO32v2 is not maintained any more.
 
[snip]

can you install 32 bit Windows XP under a Virtual Machine, like Virtualbox,
then FPC on that? The IV drip would be extended... ;)

-L.




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


[fpc-pascal] Re: DoDirSeparators and special filenames on Windows

2013-09-11 Thread Lukasz Sokol
On 10/09/13 16:35, Jürgen Hestermann wrote:
 Am 2013-09-09 22:28, schrieb Tomas Hajny:
 ...and the issue is that at least some Windows API functions happily accept 
 such paths,
 i.e. programs using such API functions accept them too.
 If FPC RTL manages to translate a path accepted by Windows
 (and other programs not compiled to FPC too) to something which is not 
 accepted by
 Windows (API) any longer, then we may consider fixing such translation.
 
 
 IMO, when a path contains two consecutive path delimiters then something is 
 wrong.
 It could also be that someone wanted to type a letter between both delimiters 
 so dropping
 one of them is trying to guess what the user wanted which leads to errors in 
 most cases.
 Suddenly a file or directory is accessed that was not meant by the user.
 A path should be correct and no more or less smart second guessing should be 
 done.

Only plausible 'smart guess' here is that '\/' or '/\' or '\\' in the path be 
converted to '\' simply, 
for the '\\?\'mode (on windows of course, Linux doesn't care about '//'s in 
path)

 Otherwise you can also start a nearest match search that tries to find 
 another directory
 in case the specified one is not found. That's something I would expect in C 
 but not in Pascal.
 And even if the WinAPI allows such flaws I don't think that Pascal 
 programmers like this too.

Nearest match search takes cpu, time and resources... 
GetLastOSError (and its format message companion) would tell us that path 
doesn't exist, will it not?

L.


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


[fpc-pascal] Re: Library callback : how do I do that?

2013-08-09 Thread Lukasz Sokol
On 09/08/13 08:28, Michael Schnell wrote:
 On 08/08/2013 02:41 PM, Lukasz Sokol wrote:
 Very well then, thanks :)
 
 I suggest that - to exclude problems that might be imposed by some
 external non-Lazarus and software not by yourself  - you do a test
 creating a combination of a Lazarus Application and a Lazarus-made
 dll (and/or so) that features a TThread in the dll and uses
 Application.QueuAsyncCall(Form1.DisplayCallFromDLL, NIL) to display
 some running counter or similar stuff.
 
 I understand for this you need to - unify the Heaps of Application
 and dll - do a call to the dll to provide the Application and the
 Form1 main form instances of the calling  program
 
 If you succeed in doing a really reliable Test implementation of
 this, I would be happy to see the source code.
 
 This could be the basis of a standard implementation of something
 similar to Delphi runtime packages.
 
 Thanks, -Michael 

I, erm, second what Sven and Henry have said - I am not creating my 
own library, but merely trying to build a wrapper...

(OT) (On a side note to the runtime packages, some years ago I had to
look for and indeed I came on someone's 'plugin system' for delphi (7) 
that ran with .dll (as opposed to .bpk where it usually is possible) 
and could add forms to your main application at runtime... needless to 
say, it was a paid-for (and IIRC with NDA attached) system; 
But I was /under impression/ that it would be as easy as having
same memory/heap manager instance for main program and for dll 
(of which some were open source), and that was the main hurdle too,
and passing the Application instance into it by using some Interfaces, 
and the dll capabilities back in the same manner; 
but before I had time to get /less/ inept on Interfaces, the demand
 for this feature has ended... 
so I can't really remember anything else out of that area, sorry.

[Also it may all be rubbish what I wrote, t'is only what I remember of
my impressions, only... I don't have any hard data of this saved anywhere
(my then-employer was really insisting on not taking this work home)...] )

-L



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


[fpc-pascal] Library callback : how do I do that?

2013-08-08 Thread Lukasz Sokol
Hello,

I am making a Pascal wrapper for a library, which states in its API description:


Note that the Callback function will be called from an independent child
thread, not from the Application’s Window thread. It should not therefore be
used to draw data directly to a Windows screen. The safest use of the callback
is to use a threadsafe interface (such as Windows messaging) to pass the
message to Windows for handling by the Windows thread.


and c(++) example

void Callback( int SerialNumber, int Event, int Data )
{
// Send the message to Windows thread for processing
PostMessage( NULL, WM_USER_MULTIPORTEVENT, Event,SerialNumber );
// Note: Data ignored. We can poll for an up-to-date
// value when this message is handled.
} 

This would be fine, IFF i was adding this to the main form of my application...
but I'm not. I'm trying to wrap this .dll in a separate unit, only communicating
to the form through a wrapper object, defined in a separate unit.
The object itself, would be created /by/ the form window, but won't be a GUI 
object,
so won't be in the message queue;

Doing a chain like:

(Setup)
(form passes its handle to the object) - (object installs callback function)
and then
(normal operation)
(form receives callback via Windows Message) - (form calls e.g OnCallback 
function of the object)

seems a bit backwards.

I can imagine, that I need to have the Callback procedure as 

procedure Callback(Port, Event, Value : Integer); stdcall;

but how do I call functions/procedures of MyObject in a threadsafe manner from 
there?

(Lazarus 1.0.10 2013-06-09, FPC 2.6.2 rev. 41613 i386-win32-win32/win64)

Sorry if it's lame,
Kind Regards,
Lukasz

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


[fpc-pascal] Re: Library callback : how do I do that?

2013-08-08 Thread Lukasz Sokol
On 08/08/13 11:52, Michael Schnell wrote:
 On 08/08/2013 12:34 PM, Lukasz Sokol wrote:
 Hello,
 
 I am making a Pascal wrapper for a library, which states in its API
 description:
 
  Note that the Callback function will be called from an
 independent child thread, not from the Application’s Window thread.
 It should not therefore be used to draw data directly to a Windows
 screen. The safest use of the callback is to use a threadsafe
 interface (such as Windows messaging) to pass the message to
 Windows for handling by the Windows thread. 
 
 AFAIU: The callback is just a callback. So you can handle it in the
 normal way (either in an application, in a command line tool without
 a main form or in a dll.) You just can't do any GUI stuff in that
 callback.
 
 I understand that you in fact don't want to do that, anyway.
 
 -Michael
 

Oh, I missed the whole point ... sorry.

in fact I DO want to be able to call gui-interfacing functions of the 
form. The library I am loading (dynamically) will be giving me callbacks
when something changes in an external USB device...
When that happens, I want to be able to do e.g.

MyObject.OnStateChange := TForm1.ShowStateChange;

and e.g. safely call ShowMessage or display a custom dialog box,

(as well as I will be calling procedures/functions of another non-vis object(s)
doing something else with the data provided by callback)

So it seems, if I call my objects' InternalCallback function from the
installed callback, then it's my object that has to care for thread safety
to the GUI then ?

(Henry Vermaak mentions QueueAsyncCall, going there...

Kind Regards,
Lukasz

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


[fpc-pascal] Re: Library callback : how do I do that?

2013-08-08 Thread Lukasz Sokol
On 08/08/13 11:58, Henry Vermaak wrote:
 On Thu, Aug 08, 2013 at 11:34:53AM +0100, Lukasz Sokol wrote:
 This would be fine, IFF i was adding this to the main form of my
 application...  but I'm not. I'm trying to wrap this .dll in a
 separate unit, only communicating to the form through a wrapper
 object, defined in a separate unit.  The object itself, would be
 created /by/ the form window, but won't be a GUI object, so won't be
 in the message queue;

 Doing a chain like:

 (Setup) (form passes its handle to the object) - (object installs
 callback function) and then (normal operation) (form receives callback
 via Windows Message) - (form calls e.g OnCallback function of the
 object)

 seems a bit backwards.

 I can imagine, that I need to have the Callback procedure as 

 procedure Callback(Port, Event, Value : Integer); stdcall;

 but how do I call functions/procedures of MyObject in a threadsafe
 manner from there?
 
 Lazarus has QueueAsyncCall, which is a thread safe, cross platform way
 of queueing method calls asynchronously.
 
 E.g. for USB hotplug notification, I register this function with my
 device library:
 
   procedure NotifyPlug(status: cint); cdecl;
   begin
 Application.QueueAsyncCall(@MainForm.NotifyAsync, status);
   end;
 
 Henry

Hello Henry,

but I would then need to make the wrapper object aware of the Application 
or its forms then?

I wanted the wrapper unit to be as self-contained as much as possible,
(so the callback function is defined in a unit that only has Classes, SysUtils 
and dynlibs as uses,
i.e. no Forms. Controls or Graphics)
but still be thread-safe w/r/t to where the wrapper object is created
(within a GUI form or /not/)

Unless I can do:

procedure Callback (...); stdcall;
begin
  {Application}.QueueAsyncCall(MyObject.CallbackNotify, ...);
end;

no?

Thanks,
Lukasz


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


[fpc-pascal] Re: Library callback : how do I do that?

2013-08-08 Thread Lukasz Sokol
On 08/08/13 12:31, Michael Schnell wrote:
 On 08/08/2013 01:15 PM, Lukasz Sokol wrote:
 but I would then need to make the wrapper object aware of the
 Application or its forms then?
 This is provided by Runtime Packages with Delphi.
 
 Lazarus does not support Runtime packages (yet) so you are quite on
 your own to implement something similar.
 
 Hopefully the Wiki might provide some hints.
 
 -Michael

Hello Michael,

i see then, having a chain

(callback procedure) - MyObject.CallbackNotify - (processing callback data) 
- 
call a function within a form unit that does Application.QueueAsyncCall() 

is really my best bet then?

Lukasz

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


[fpc-pascal] Re: Library callback : how do I do that?

2013-08-08 Thread Lukasz Sokol
On 08/08/13 13:04, Michael Schnell wrote:
 On 08/08/2013 01:42 PM, Lukasz Sokol wrote:
 i see then, having a chain

 (callback procedure) - MyObject.CallbackNotify - (processing callback 
 data) -
 call a function within a form unit that does Application.QueueAsyncCall()

 is really my best bet then?

 I don't see another way.
 
 And I suppose all the steps can and should  be debugged separately.
 
 -Michael

Very well then, thanks :)

Lukasz


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


[fpc-pascal] Re: Console Encoding in Windows (Local VS. UTF8)

2013-07-11 Thread Lukasz Sokol
On 10/07/2013 13:38, Graeme Geldenhuys wrote:
 On 2013-07-10 11:19, Tomas Hajny wrote:

 Sure, but you can't select just any True Type fonts for console windows
 (only Lucida is offered in WinXP;
 
 And is so since Win95. Just amazing that Windows Console is so far
 behind other platforms - it's rather ridiculous if you think about it.
 
 If I used Windows, I would install a different console application —
 there must be better after-market ones out there. But yes, this probably
 doesn't solve your or your clients problems.
 

I seriously doubt it...

I mean, in the olden days, the cmd program was actually a fully/partially 
[delete inappropriate]
DOS compatible virtual machine, starting with : being able to run real x86 mode 
programs...
It wasn't a shell as *nix has, never was meant to be...

You'd have more luck using DosBOX emulator these days... 

 Anyway, here is some background information on Microsoft's terrible
 Console Window.
 
 
 Why are console windows limited to Lucida Console and raster fonts?
 
  http://blogs.msdn.com/b/oldnewthing/archive/2007/05/16/2659903.aspx
 
 Here is how you can add more fonts — but you are on your own (the words
 from Microsoft):
 
   http://support.microsoft.com/kb/247815
 
 
 Regards,
   G.
 

-L;)


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


[fpc-pascal] (OT) Re: How to use UART of ARM platforms (e.g. Raspberry Pi ) through free Pascal?

2013-07-04 Thread Lukasz Sokol
On 04/07/2013 11:08, Dennis Poon wrote:
 thanks. I am not using the fpc email as it seems off topic.
 
 May I know the exact brand and model number of the adapter you used? 
 I have an ATEN usb-to-serial cable (UC-232A) but I am not sure how to
 connect its serial pins to rs-485 's DIFFERENTIAL LINES and how to
 set that adapter into half-duplex translation mode.
 
 Dennis
 
[...]


(apparently it went into FPC list anyway)

For RS485 adaptation, use a MAX232 like chip (to convert +-12 to ttl) 
and then a RS485 transceiver chip; 

A MAX232 has 4 [IIRC] level changers, 2 in each direction; so you can
use one pair to convert tx/rx, and one of the remaining ones in 232-ttl 
direction,
to convert one RS232 signal to switch the RS485 trx into 'sending' mode;

Of course you need an additional +5V supply to the above too.

HTH,
-L.

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


[fpc-pascal] Re: (OT) Re: How to use UART of ARM platforms (e.g. Raspberry Pi ) through free Pascal?

2013-07-04 Thread Lukasz Sokol
On 04/07/2013 12:03, Michael Schnell wrote:
 On 07/04/2013 12:52 PM, Lukasz Sokol wrote:
 For RS485 adaptation, use a MAX232 like chip (to convert +-12 to
 ttl) and then a RS485 transceiver chip;
 
 If you want to create hardware anyway, better use a PIC24 (pr PIC32)
 chip with USB plus a RS485 tranceiver chip. So you get rid of the 
 ATEN usb-to-serial cable (UC-232A) and you have both sides of USB
 under your control so that you can do the USB procedure you want.
 
+1 if OP wants to create his own hw and sw for that purpose

 Another way is using a pre-programmed PIC chip available by Microchip
 with USB to-Serial software plus a RS485 tranceiver chip.
 
+1 if OP wants to use standard hw...

-L;

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


[fpc-pascal] Re: (OT) Re: How to use UART of ARM platforms (e.g. Raspberry Pi ) through free Pascal?

2013-07-04 Thread Lukasz Sokol
On 04/07/2013 16:24, Mark Morgan Lloyd wrote:
 Lukasz Sokol wrote:
 On 04/07/2013 12:03, Michael Schnell wrote:
 On 07/04/2013 12:52 PM, Lukasz Sokol wrote:
 For RS485 adaptation, use a MAX232 like chip (to convert +-12
 to ttl) and then a RS485 transceiver chip;
 If you want to create hardware anyway, better use a PIC24 (pr
 PIC32) chip with USB plus a RS485 tranceiver chip. So you get rid
 of the  ATEN usb-to-serial cable (UC-232A) and you have both
 sides of USB under your control so that you can do the USB
 procedure you want.
 
 +1 if OP wants to create his own hw and sw for that purpose
 
 Another way is using a pre-programmed PIC chip available by
 Microchip with USB to-Serial software plus a RS485 tranceiver
 chip.
 
 +1 if OP wants to use standard hw...
 
 Discussion elsewhere suggests that the RPi has an internal 16550
 port, and controlling the 485 signals using e.g. CTS might be
 viable.

Yeah I seem to remember http://www.hobbytronics.co.uk/raspberry-pi-gpio-pinout
I guess for 485 direction setting, one of GPIO will need to be used;
Sigh. Why do people keep reinventing ethernet starting from half duplex without
galv. separation ? :)

 
 In any event, my experience is that USB-serial converters are very
 poor for anything that involves accurate timing, and I suspect that
 controlling a 485 transceiver in conjunction with one would be
 problematic. I think I asked FTDI about this a couple of years ago,
 and was told that their hardware had facilities that would help but
 exploiting them would take a non-standard driver.
 
Well that's a question of OP's project goals agenda...

-L;

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


[fpc-pascal] Re: Odyssey: SSockets and Threads.

2013-04-30 Thread Lukasz Sokol
On 29/04/2013 17:58, waldo kitty wrote:
 On 4/29/2013 06:04, Reinier Olislagers wrote:
 On 29-4-2013 11:50, Lukasz Sokol wrote:
 On 27/04/2013 16:06, silvioprog wrote:
 2013/4/27 Sven
 Barthpascaldragon-gM/ye1e23mwn+bqq9rb...@public.gmane.org

 
mailto:pascaldragon-gM/ye1e23mwn+bqq9rb...@public.gmane.org
 
 On 26.04.2013 21:38, silvioprog wrote: Oopppss, sorry.
 I'll delete it. :X
 
 Too late, gmane mail to news already stored it too.
 
 What? The link that shows 404 page not found? Or the actual
 content?
 
 the original message had a link and the actual code... deleting the
 link is one thing but the code is already distributed around the
 world and cannot be deleted by the OP...
 

I guess the devs don't use gmane so they can just cat /dev/urandom  the 
mailbox file 
with the offending code ;) 3 times ;) interleaved with cat /dev/zero ;) same 
for the
owner of the forum server if it got there.

as for the rest of us, we should be fine as long as Silvio's answer won't pop 
up 
or be referenced anywhere, so e.g. google won't index it somewhere visible...
which probably is why we should end this thread immediately ;)

L.

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


[fpc-pascal] Re: Odyssey: SSockets and Threads.

2013-04-29 Thread Lukasz Sokol
On 27/04/2013 16:06, silvioprog wrote:
 2013/4/27 Sven Barth pascaldra...@googlemail.com
 mailto:pascaldra...@googlemail.com
 
 On 26.04.2013 21:38, silvioprog wrote:
 
 Select in socket of Delphi 2007 (a friend sent it to me: 
 http://www.sendspace.com/file/__06ev02
 http://www.sendspace.com/file/06ev02):
 
 
 Gaahhh!!! Don't simply send Delphi code to this list! Did you ever
 heard of stuff like clean room reverse engineeering?!
 
 Regards, Sven
 
 
 Oopppss, sorry. I'll delete it. :X
 
Too late, gmane mail to news already stored it too.

L.

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


  1   2   >