Re: [fpc-pascal] FPC releases for Win64 - 2.6.2 & 2.6.4 versus 3.0.0
In our previous episode, Dimitrios Chr. Ioannidis said: > 2016-04-07 19:07, Graeme Geldenhuys ??: > > How do I know if a program (executable) is 32-bit or 64-bit under > > Windows? Using Unix-like OSes, I can simply use the "file" > > command. What is the equivalent under Windows? > > you can use file ;) > > http://gnuwin32.sourceforge.net/packages/file.htm > > http://superuser.com/questions/103071/quick-way-to-tell-if-an-installed-application-is-64-bit-or-32-bit or PE Explorer iirc even some objdump builds (maybe even the ones that come with FPC) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC releases for Win64 - 2.6.2 & 2.6.4 versus 3.0.0
Hi Graeme, Στις 2016-04-07 19:07, Graeme Geldenhuys έγραψε: How do I know if a program (executable) is 32-bit or 64-bit under Windows? Using Unix-like OSes, I can simply use the "file" command. What is the equivalent under Windows? you can use file ;) http://gnuwin32.sourceforge.net/packages/file.htm http://superuser.com/questions/103071/quick-way-to-tell-if-an-installed-application-is-64-bit-or-32-bit regards, -- Dimitrios Chr. Ioannidis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC releases for Win64 - 2.6.2 & 2.6.4 versus 3.0.0
On 2016-04-07 17:11, Michael Van Canneyt wrote: > > The windows team doesn't think there are sufficient reasons/arguments > for a 64-bit native compiler. Lazy buggers! ;-) > (So, I roll my own. Luckily, this is not that hard) I'll do the same, thanks. >> How do I know if a program (executable) is 32-bit or 64-bit under >> Windows? Using Unix-like OSes, I can simply use the "file" >> command. What is the equivalent under Windows? > > Right-click in explorer, 'Properties', and then 'details' or so ? Nope, that's the firs place I looked. I've got 64-bit Windows 7 installed. The "Properties -> Details" dialog list the file type, version, copyright etc... but nowhere does it say 32-bit or 64-bit. I can see the "*32" in the Windows Task Manager which indicates 32-bit or 64-bit applications. But that is only useful for long running apps.For very fast running applications (eg: many console utilities) it appears and disappears to quickly for me to see. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC releases for Win64 - 2.6.2 & 2.6.4 versus 3.0.0
On Thu, 7 Apr 2016, Graeme Geldenhuys wrote: Hi, No my Win64 VM I have FPC 2.6.2 and 2.6.4 installed using the official FPC installers. For example: fpc-2.6.4.x86_64-win64.exe I wanted to upgrade my VM to FPC 3.0.0, but I don't seem to find an official Win64 release like prior versions. All I can find as a what I assume is a 32-bit cross-complier to win64: fpc-3.0.0.i386-win32.cross.x86_64-win64.exe Why did FPC stop making official native win64 compilers? Or is this just a naming convension change? The windows team doesn't think there are sufficient reasons/arguments for a 64-bit native compiler. (So, I roll my own. Luckily, this is not that hard) ps: How do I know if a program (executable) is 32-bit or 64-bit under Windows? Using Unix-like OSes, I can simply use the "file" command. What is the equivalent under Windows? Right-click in explorer, 'Properties', and then 'details' or so ? ps #2: Why doesn't the Free Pascal SourceForge page contain a "Win64" folder. The prior FPC releases, the native 64-bit installations are filed under the "Win32" folder. This seems a bit confusing. See above. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] FPC releases for Win64 - 2.6.2 & 2.6.4 versus 3.0.0
Hi, No my Win64 VM I have FPC 2.6.2 and 2.6.4 installed using the official FPC installers. For example: fpc-2.6.4.x86_64-win64.exe I wanted to upgrade my VM to FPC 3.0.0, but I don't seem to find an official Win64 release like prior versions. All I can find as a what I assume is a 32-bit cross-complier to win64: fpc-3.0.0.i386-win32.cross.x86_64-win64.exe Why did FPC stop making official native win64 compilers? Or is this just a naming convension change? ps: How do I know if a program (executable) is 32-bit or 64-bit under Windows? Using Unix-like OSes, I can simply use the "file" command. What is the equivalent under Windows? ps #2: Why doesn't the Free Pascal SourceForge page contain a "Win64" folder. The prior FPC releases, the native 64-bit installations are filed under the "Win32" folder. This seems a bit confusing. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On Thursday 07 April 2016 16:20:16 Santiago A. wrote: > El 07/04/2016 a las 14:00, Luiz Americo Pereira Camara escribió: > > I enconter the following pattern frequently (simplified): > > > > SQL: > > Select * From Customers Where FieldX = 1 > > > > Later i need a similar query that uses a different filter like > > > > Select * From Customers Where FieldX = 1 and FieldY = :paramy > > I remember a component of RxLib named TRxQuery. It had a published > property "macros" of type TParams, so you could write this sql > > Select * From Customers Where FieldX = 1 and (%extrafilter). In MSEgui SQL properties are of type TSQLStringList. TSQLStringList has a property "Macros" which is an array of TSQLMacroItem. TSQLMacroItem.Value inherits from TSQLStringList, so it is possible to build a macro tree which items can be accessed by a name path (TMacroProperty.ItemByNames()). " select ${fields} from ${table} where ${filter} " in example http://mseide-msegui.sourceforge.net/pics/sqlmacros.png expands to " select FIELD1 from TABLE1 where FIELD1 = 'abc' " Martin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On Thu, Apr 7, 2016 at 12:30 PM, Luiz Americo Pereira Camara wrote: > Thanks for all the responses > > The Marcos' one is particular interesting since goes in a direction a did > not think earlier Thanks. I do this for years. The major advantage, I think, is doesn't need to change the SQL in pieces. You can put the original SQL in a Query component or file integrally. The DBMS engine is smarter enough to optimize all that. Best regards, Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
Thanks for all the responses The Marcos' one is particular interesting since goes in a direction a did not think earlier Luiz 2016-04-07 12:06 GMT-03:00 Graeme Geldenhuys : > On 2016-04-07 13:47, Michael Thompson wrote: > > This moves it up that list... > > I can give you many more reason to move it up even further. ;-) tiOPF is > a treasure trove of goodies (for DB and non-DB projects). > > Regards, > - Graeme - > > ___ > 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] Create dynamic SQL according to available params
On 2016-04-07 13:47, Michael Thompson wrote: > This moves it up that list... I can give you many more reason to move it up even further. ;-) tiOPF is a treasure trove of goodies (for DB and non-DB projects). Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
El 07/04/2016 a las 14:00, Luiz Americo Pereira Camara escribió: > I enconter the following pattern frequently (simplified): > > SQL: > Select * From Customers Where FieldX = 1 > > Later i need a similar query that uses a different filter like > > Select * From Customers Where FieldX = 1 and FieldY = :paramy I remember a component of RxLib named TRxQuery. It had a published property "macros" of type TParams, so you could write this sql Select * From Customers Where FieldX = 1 and (%extrafilter). After setting de sql property, in design time was added an item to macros with name 'extrafilter' of type string and initial value '(0=0)', In run time you could do: RxQuery1.Macros.ParamByName('extrafilter'):='(0=0)'; or RxQuery1.Macros.ParamByName('extrafilter'):='FieldY=:paramy'; (I think there was also a RxQuery1.MacroByName to shorten RxQuery1.Macros.ParamByName) When you prepared the sql, macros where expanded in the sql. The was also a property named RealSQL of TString, it was the sql statement after macro substitution. (I'm not sure if RealSQL was public or I modified the library to make it public) When you changed a macro it was like changing the sql. You needed to prepare again the query. It is not that different from saving the original sql string and replacing certain parts, (in fact, I have done things like that). But it was handy. -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On Thu, Apr 7, 2016 at 9:00 AM, Luiz Americo Pereira Camara wrote: > > I enconter the following pattern frequently (simplified): > > SQL: > Select * From Customers Where FieldX = 1 > > Later i need a similar query that uses a different filter like > > Select * From Customers Where FieldX = 1 and FieldY = :paramy > > Is there any code that given a SQL Template would generate the second filter > when paramy is available and keep blank when not available? You can do this: ===begin=== select * from Customers where 1=1 and FieldX = 1 and (:paramy = -1 or FieldY = :paramy) ===end=== if you do not want to filter, just pass -1 (or whatever). Otherwise, pass the real value. For MSSQL I like to declare a variable like this: ===begin=== declare @paramy int = :paramy ... and (@paramy = -1 or FieldY = @paramy) ===end=== Regards, Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On 7 April 2016 at 20:20, Graeme Geldenhuys wrote: > On 2016-04-07 13:00, Luiz Americo Pereira Camara wrote: > > If there's not in pascal, someone knows such templating in another > > languages? The hard part is getting a flexible and functional syntax > > I have written such code for the tiOPF project, but it should be quick > to detach any tiOPF dependencies. The code is well unit tested too (see > the tiCriteria_TST.pas unit). The unit test code is also good for usage > examples. > > It can't handle all complex cases, but is fairly good. It also has an > option to inject any SQL as-is, in case you need a complex WHERE clause. > > http://geldenhuys.co.uk/tiopf/ticriteria/index.html > > In summary, you use the TtiCriteria class to add your desired criteria, > then call tiCriteriaAsSQL(...) which will generate the SQL WHERE clause > string for you. Interesting. I've been meaning to look into tiOPF for a while. Part of that massive TODO list :-) This moves it up that list... Mike ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On 7 April 2016 at 20:06, Luiz Americo Pereira Camara < luizameri...@gmail.com> wrote: > Any chance sharing the code or at least the syntax? (I realise I'm hijacking your conversation with Michael - apologies for that, but this interests me) My code to initialise the grid (which hides all _ID columns) Procedure InitialiseDBGrid(oGrid: TDBGrid; oDataset: TDataset; bHideIDs: Boolean = False); <...> Begin If not oDataset.Active Then Exit; oDataset.DisableControls; Try <...> oDataset.First; For iTemp := oGrid.Columns.Count - 1 Downto 0 Do Begin oColumn := oGrid.Columns[iTemp]; oField := oColumn.Field; <...> // Hide the ID columns if so requested If (bHideIDs) And (Copy(oField.FieldName, Length(oField.FieldName) - 1, 2) = 'ID') Then Begin oColumn.Visible := False; oField.Visible := False; End; <...> End; <...> oDataset.First; Finally oDataset.EnableControls; End; End; Without getting into my architecture too deeply, I have code that hooks into the Master dataset OnAfterScroll, and the Macro's for each Detail data are handled simply by the follow sort of code... Function TfrmSQLExplorer.ReplaceCommonMacros(sSQL: String): String; Begin Result := sSQL; Result := FindReplace(Result, ':UserDate', FormatDateTime('-mm-dd', dtUserDate.Date)); Result := FindReplace(Result, ':Time', FormatDateTime('HH:mm:ss', Now)); Result := FindReplace(Result, ':Date', FormatDateTime('-mm-dd', Now)); Result := FindReplace(Result, ':Database', FClient.DatabaseName); Result := FindReplace(Result, ':Repository', FClient.DatabaseName + '_Rep'); Result := FFilters.ReplaceMacros(Result); End; (FFilters is essentially a list of frames that each contain a DBlookupCombo) and Function TdckMacros.ReplaceCommonMacros(oExclude: TDataset; sSQL: String): String; Var i: Integer; iField: Integer; oField: TField; oDataset: TDataset; sReplace: String; Begin Result := sSQL; For i := 0 To FDatasets.Count - 1 Do Begin oDataset := Dataset[i]; If (oDataset <> oExclude) Then For iField := 0 To oDataset.Fields.Count - 1 Do Begin oField := oDataset.Fields[iField]; sReplace := oField.AsString; If (oField.DataType = ftInteger) And (sReplace = '') Then Result := FindReplace(Result, ':' + oField.FieldName, '-9') Else Result := FindReplace(Result, ':' + oField.FieldName, sReplace); End; End; End; You don't need to follow my architecture (I hope ;-) ), just the concept of cycling through a dataset, treating all columns as potential Macros for replacement. Sure, there's issues in the above code that are on my TODO, but have been there for a while, but as I construct all the SQLs used by this code, I've got used to working around those issues :-) Mike ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
Graeme Geldenhuys wrote: Are there pros or cons to either? The fashion of the day. Apparently, programmers are (supposed to be) not intelligent enough to work with pointers themselves -- if needed. So the compiler does that for you and declares everything a pointer automatically. Same with "magic" types such as PChar and "AnsiString". Poor man's programming in my view, but as said, that's the fashion of the day. Needless to say that a program where the programmer does have full control himself (and uses that to the advantage) is both faster and more reliable than a program where things are handled "automagically". Regards, Adriaan van Os ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On 7 April 2016 at 20:00, Luiz Americo Pereira Camara < luizameri...@gmail.com> wrote: > Is there any code that given a SQL Template would generate the second filter when paramy is available and keep blank when not available? Nope, or at least I don't think so. I've spent a long time looking as well. Been meaning to bring up the discussion either here or in the forum I ended up implementing my own "Macro" functionality. Unfortunately I've broken a few rules and tied the functionality to the UI, making it hard to share. I need this all the time. My primary usage is in Master-Detail relationships, where I always want the Master to contain an "ALL" option. To achieve I write SQL's like... Select Incident_Type As "Incident_Type", Description As "Description", 'Where Incident_Type=''' || Incident_Type || As "Filter_ID" From PIG Union Select '(ALL)' As "Incident_Type", 'All Types' As "Description", '' As "Filter_ID" From DUAL The first Select returns the Master Table, the second Select appends my ALL. Note that "Filter_ID" contains my full SQL Where clause. Over in my Detail SQL, I can write stuff like Select * From Incident :Filter_ID Order By Incident_Type, Incident I implement the detail refresh myself (easy), and I implement the Macro substitution myself before executing the Detail SQL. (Any SQL field ending in _ID is automatically hidden in my code) I use this so often, and in so many different ways (Macro's don't have to contain Where clauses, they can be any SQL elements, including simple data), that I cannot consider SQL development without it. And as such, I've often wondered how do others deal with this... Mike ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On 2016-04-07 13:00, Luiz Americo Pereira Camara wrote: > If there's not in pascal, someone knows such templating in another > languages? The hard part is getting a flexible and functional syntax I have written such code for the tiOPF project, but it should be quick to detach any tiOPF dependencies. The code is well unit tested too (see the tiCriteria_TST.pas unit). The unit test code is also good for usage examples. It can't handle all complex cases, but is fairly good. It also has an option to inject any SQL as-is, in case you need a complex WHERE clause. http://geldenhuys.co.uk/tiopf/ticriteria/index.html In summary, you use the TtiCriteria class to add your desired criteria, then call tiCriteriaAsSQL(...) which will generate the SQL WHERE clause string for you. tiOPF is available on SourceForge or Github: https://sourceforge.net/p/tiopf/code/ci/tiopf2/tree/ tiCriteria.pas lives in the Core/ directory. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On Thu, 7 Apr 2016, Luiz Americo Pereira Camara wrote: 2016-04-07 9:03 GMT-03:00 Michael Van Canneyt : On Thu, 7 Apr 2016, Luiz Americo Pereira Camara wrote: Is there any code that given a SQL Template would generate the second filter when paramy is available and keep blank when not available? I have not found such code. I rolled my own. Any chance sharing the code or at least the syntax? No, that was for a commercial project. sorry. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
2016-04-07 9:03 GMT-03:00 Michael Van Canneyt : > > > On Thu, 7 Apr 2016, Luiz Americo Pereira Camara wrote: > > >> Is there any code that given a SQL Template would generate the second >> filter when paramy is available and keep blank when not available? >> >> >> > I have not found such code. I rolled my own. > > Any chance sharing the code or at least the syntax? Thanks in advance Luiz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Create dynamic SQL according to available params
On Thu, 7 Apr 2016, Luiz Americo Pereira Camara wrote: I enconter the following pattern frequently (simplified): SQL: Select * From Customers Where FieldX = 1 Later i need a similar query that uses a different filter like Select * From Customers Where FieldX = 1 and FieldY = :paramy Is there any code that given a SQL Template would generate the second filter when paramy is available and keep blank when not available? Like Select * From Customers Where FieldX = 1 ${paramtemplate paramy} The param not necessarily have to be in TParams, in my case the param is both in a JSON object and in TParams I have not found such code. I rolled my own. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Create dynamic SQL according to available params
I enconter the following pattern frequently (simplified): SQL: Select * From Customers Where FieldX = 1 Later i need a similar query that uses a different filter like Select * From Customers Where FieldX = 1 and FieldY = :paramy Is there any code that given a SQL Template would generate the second filter when paramy is available and keep blank when not available? Like Select * From Customers Where FieldX = 1 ${paramtemplate paramy} The param not necessarily have to be in TParams, in my case the param is both in a JSON object and in TParams If there's not in pascal, someone knows such templating in another languages? The hard part is getting a flexible and functional syntax Luiz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
El 07/04/2016 a las 13:04, Graeme Geldenhuys escribió: > On 2016-04-07 11:58, Santiago A. wrote: >> Moreover, if the object uses classes instances that must be freed, you >> also must call destructor, then any advantage is over. > Technically yes, but as a rule of thumb, I *never* use Class objects > inside an Object object. That just seems messy. Usually, me neither. But I often use open arrays that can grow. Although open arrays are pointers that use heap, they are supposed to be liberated when the object is removed from stack, but in fpc 2.6.4 didn't properly. and 3.0.0 I have found strange behaviors and errors if I don't call a constructor. Nevertheless, I stick on my idea that even if objects have virtual methods, they should be initializated properly even if you don't call the constructor. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
On 2016-04-07 11:58, Santiago A. wrote: > Moreover, if the object uses classes instances that must be freed, you > also must call destructor, then any advantage is over. Technically yes, but as a rule of thumb, I *never* use Class objects inside an Object object. That just seems messy. Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Class vs Object type
El 06/04/2016 a las 13:23, Graeme Geldenhuys escribió: > "The difference between objects and classes is mainly that an object is > allocated on the stack, as an ordinary record would be, and that classes > are always allocated on the heap." > > Are there pros or cons to either? > > Regards, > - Graeme - A nice pro of objects is that, if you don't need a constructor, you can forget about calling create and free. If you need a constructor (ie it has virtual methods), there is not that advantage. Moreover, if the object uses classes instances that must be freed, you also must call destructor, then any advantage is over. Maybe a little performance gain using stack instead of heap. A nice feature would be default creator and destructor: ej. type TMyObject=Object constructor default; Destructor default; end; procedure foo; var obj:TMyObject; begin // Default constructor (if it has) automatically called here obj.; obj.zzz; // Default destructor automatically called here end; Or even with parameters type TMyObjectParam=Object constructor default(n:Integer); Destructor default; end; procedure foo; var obj1:TMyObjectParam(7); obj2:TMyObjectParam; begin // Default constructor of obj1 automatically called here with param 7 // Default constructor of obj2 not called because the declaration has no parameters obj1.; obj1.zzz; if condition then begin obj2.Default(x); // Constructor must be called manually obj2.; obj2.zzz; end; // Default destructor of obj2 automatically called here if it has been initializated // Default destructor of obj1 automatically called here end; -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal