Re: [fpc-pascal] Writing a Console App in FreePascal that connects to MySQL
How should FConnection and FTransaction be declared or are the declared in a library somewhere? I have the following source code which is based on the web site http://wiki.freepascal.org/SqlDBHowto, but does not compile: There was typo Change FConnection to MyConnection and FTransaction to MyTransaction in your example. -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Descriptor in Windows ?
On Wed, 25 Mar 2015, Marc Weustink wrote: fredvs wrote: Hello. Sorry to sorry to bother you with that file descriptors again... ;-( There are some answers there on mpg123 forum. They explain that simple stdin/stdout file descriptors would work. Of course all what they explained is in C ;-( OK, but how can i use simple stdin/stdout file descriptors in Pascal ? What is the code to retrieve that stdin/stdout file descriptors in Windows? What in unix is used as filedescriptor is in general in windows used as handle (filehandle/sockethandle) Googling for windows msdn stdin resulted in: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx I've no clue why a lib should need this (and if a non console app would have any) IMHO: The call is needed because unlike unix, stdinput, output and error file descriptors are not equal to 0 1 2. So you need a call to retrieve the actual value. The system unit calls these functions and stores the result in the variables I mentioned. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Descriptor in Windows ?
Am 26.03.2015 08:26 schrieb Michael Van Canneyt mich...@freepascal.org: On Wed, 25 Mar 2015, Sven Barth wrote: On 25.03.2015 19:57, fredvs wrote: PS: Why everything must be so compilcated with Windows ? It's not if developers wouldn't decide to make their libraries so *nix centric... I don't understand this remark ? What is so *nix centric about a file descriptor ? Per se nothing. But if that can only handle StdIO pseudo handles in Windows then I'd definitely call that *nix-centric or at least not fully useable on Windows. I personally would have declared a platform specific handle type like we have in our RTL and then would have used the OS specific routines to handle them. Also I assume that on Win64 that fd type used by mpg123 is still int while a Handle there is a 64-bit value (I didn't check the code so this is only an assumption) making it even more incompatible with the Windows routines... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Descriptor in Windows ?
Hello. For info, here answer from mpg123 creator = __ 4) Assisgn input pipe stream = mpg123_open_fd(MyMPHandle,InHandle); = Crash on Windows, OK on Linux. I don't have my head wrapped around the pascal bindings, but are you handing your pipe handle to mpg123_open_fd() without change? What should the mpg123 C code, expecting a C library file descriptor, do with your handle created in Pascal/Delphi with whatever runtime in the background? File descriptors may be compatible, but don't have to. If that is really the case here, it would be best not to include mpg123_open_fd() in a Pascal binding at all, or altenatively, make it a wrapper that actually used mpg123_open_handle() and handles the I/O conversion itself. As I said, I didn't look closer, but it appears to me that you're just lucky on Linux since Pascal and C share more runtime environment. Alrighty then, Thomas - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/File-Descriptor-in-Windows-tp5721448p5721507.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
Re: [fpc-pascal] File Descriptor in Windows ?
On Wed, 25 Mar 2015, Sven Barth wrote: On 25.03.2015 19:57, fredvs wrote: PS: Why everything must be so compilcated with Windows ? It's not if developers wouldn't decide to make their libraries so *nix centric... I don't understand this remark ? What is so *nix centric about a file descriptor ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Descriptor in Windows ?
fredvs wrote: Hello. Sorry to sorry to bother you with that file descriptors again... ;-( There are some answers there on mpg123 forum. They explain that simple stdin/stdout file descriptors would work. Of course all what they explained is in C ;-( OK, but how can i use simple stdin/stdout file descriptors in Pascal ? What is the code to retrieve that stdin/stdout file descriptors in Windows? What in unix is used as filedescriptor is in general in windows used as handle (filehandle/sockethandle) Googling for windows msdn stdin resulted in: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx I've no clue why a lib should need this (and if a non console app would have any) BTW, back to your original question, I looked at the docs for mpg123_open_fd() but it absolutely clueless about the second argument Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Writing a Console App in FreePascal that connects to MySQL
I was trying to see how to write a Console Appication in FreePascal that will connect to MySQL. I know how to do this in c, but thought it would be interesting to be able to do it in Pascal. How should FConnection and FTransaction be declared or are the declared in a library somewhere? I have the following source code which is based on the web site http://wiki.freepascal.org/SqlDBHowto, but does not compile: Program TestMysql; Uses sqldb, mysql55conn; Var MyConnection: TSQLConnector; MyTransaction: TSQLTransaction; MyQuery:TSQLQuery; function GetQuery : TSQLQuery; var MyQuery : TSQLQuery; begin MyQuery := TSQLQuery.Create; MyQuery.Database := FConnection; MyQuery.Transaction := FTransaction; GetQuery := MyQuery; end; procedure CreateTransaction; begin MyTransaction := TSQLTransaction.Create; MyTransaction.Database := MyConnection; end; Procedure CreateConnection; Begin MyConnection := TSQLConnector.Create(nil); MyConnection.ConnectorType := 'MySQL 5.5'; MyConnection.Hostname := '127.0.0.1'; MyConnection.DatabaseName := 'MyDB'; MyConnection.UserName := 'MyUser'; MyConnection.Password := 'MyPassword'; End; Begin CreateConnection; CreateTransaction; MyQuery := GetQuery; MyQuery.SQL.Text := 'select ObjIdx, ObjCon from object' + 'Order By ObjCon, ObjIdx'; MyConnection.Open; MyQuery.Open; If MyConnection.Connected Then Begin While Not MyQuery.eof Do Begin WriteLn(MyQuery.FieldByName('ObjIdx').AsString, MyQuery.FieldByName('ObjCon').AsString); MyQuery.Next; End; End Else WriteLn('Failure'); MyQuery.Close MyConnection.Close; MyQuery.Free MyConnection.Free; MyTransaction.Free; End. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal