Writing $$external extensions with QLib
Writing $$external extensions with QLib
Firstly, an (little long) introduction to explain why I have wished this topic.
Recentely I have decided to write some extensions for QL plateforms using Externals QLIB tools which was fairly new to me. At the begining it seemed very easy to write some Basic PROCs, compile, LRESPR binary et have resident extensions ready to use.
But when I wanted something more serious to be done, I realized that it was quite difficult to make programs work in a table and secure way on different systems.
So, I started interesting exploring and learning period to find out some useful and fundamentals rules, at least not documented enough AFAIK, but necessary.
I wanted to share my experience here and discuss improvements and solutions that could be found to reduce cavities and issues in this likely inacheved implementation under QLib.
I will start here with a minor and general point about the QLib Run time which is crucial when writing and using externals. We absolutely need to use the right version, modified, patched, repatched...Otherwise, things go very wrong and very very often crash and freeze the system.
I tried several packages and patch programs but nothing really worked for me. I finally found the only one run time library that really worked, from QLiberator page on Dilwyn site (obviously), over all my QL plateforms.
This one is untitiled "QLIB_RUN modified 2" (qlibrunmod2.zip from unknown author) with a very short description saying "To get External compiled procedures working on SMSQ/E systems". Indeed it really works on SMSQ/E but also on all systems that I could tested (SGC/Minerva/SMSQ, Q40, QPC2, QDOS/JS).
I don't know if anyone can confirm this and if Yes, it will be a good idea to be clairely stated some where and may be included in "official" QLiberator kit.
it's really useful not to have to get embeded this Run Time in each external extension because extensions reside all time in memory (unless you OVERLAY - for QLib fluidely users). I wrote some complexes externals within 3-4 KBytes for binary, while Run Time is bigger than 10 Kbytes.
Next time, I will address how Exit/RETurn from an External extension without crash/freeze the system...Not trivial.
Recentely I have decided to write some extensions for QL plateforms using Externals QLIB tools which was fairly new to me. At the begining it seemed very easy to write some Basic PROCs, compile, LRESPR binary et have resident extensions ready to use.
But when I wanted something more serious to be done, I realized that it was quite difficult to make programs work in a table and secure way on different systems.
So, I started interesting exploring and learning period to find out some useful and fundamentals rules, at least not documented enough AFAIK, but necessary.
I wanted to share my experience here and discuss improvements and solutions that could be found to reduce cavities and issues in this likely inacheved implementation under QLib.
I will start here with a minor and general point about the QLib Run time which is crucial when writing and using externals. We absolutely need to use the right version, modified, patched, repatched...Otherwise, things go very wrong and very very often crash and freeze the system.
I tried several packages and patch programs but nothing really worked for me. I finally found the only one run time library that really worked, from QLiberator page on Dilwyn site (obviously), over all my QL plateforms.
This one is untitiled "QLIB_RUN modified 2" (qlibrunmod2.zip from unknown author) with a very short description saying "To get External compiled procedures working on SMSQ/E systems". Indeed it really works on SMSQ/E but also on all systems that I could tested (SGC/Minerva/SMSQ, Q40, QPC2, QDOS/JS).
I don't know if anyone can confirm this and if Yes, it will be a good idea to be clairely stated some where and may be included in "official" QLiberator kit.
it's really useful not to have to get embeded this Run Time in each external extension because extensions reside all time in memory (unless you OVERLAY - for QLib fluidely users). I wrote some complexes externals within 3-4 KBytes for binary, while Run Time is bigger than 10 Kbytes.
Next time, I will address how Exit/RETurn from an External extension without crash/freeze the system...Not trivial.
Re: Writing $$external extensions with QLib
It is good to hear that the latest QLIB_RUN works well on all your systems. This should mean that you could have just one Boot file unmodified which would work on all your systems.HAOUI wrote: This one is untitiled "QLIB_RUN modified 2" (qlibrunmod2.zip from unknown author) with a very short description saying "To get External compiled procedures working on SMSQ/E systems". Indeed it really works on SMSQ/E but also on all systems that I could tested (SGC/Minerva/SMSQ, Q40, QPC2, QDOS/JS).
Next time, I will address how Exit/RETurn from an External extension without crash/freeze the system...Not trivial.
I have written a Qlib external called DCOPY, the 'D' standing for DATE. So, I can DCOPY "File_A" TO "File_B", and it will copy the file including the DATE. This only works on SMSQ/E. One thing I have to remember is to always use the quote marks, else it won't work.
I'll look forward to reading your next article on returning from such externals without crashing the whole works.
Re: Writing $$external extensions with QLib
This is what I have observed on my several systems at least with QLIB V3.36 but I don't know if still true with earlier versions. Will be good to have more feedback.It is good to hear that the latest QLIB_RUN works well on all your systems. This should mean that you could have just one Boot file unmodified which would work on all your systems.
I totaly agree. I don't like that COPY modify date of the file while it has not been modified.I have written a Qlib external called DCOPY, the 'D' standing for DATE. So, I can DCOPY "File_A" TO "File_B", and it will copy the file including the DATE.
Backup option in QPAC2 does not modify date but there is no equivalent command.
Passing name paramaters to $$external is a real cavity especially with PARNAM$() and PARSTR$() FUNCtions not working under QLIB.One thing I have to remember is to always use the quote marks, else it won't work.
I spent a lot of time exploring this point and wrote a program to monitor name tables of jobs. I understand now what is going on but still unable to find a reliable solution. I would like to rewrite PARNAM$() and PARSTR$() that work with $$external but I need some more information on how QLIB store some pointers in the OBJ file (may be Martin could help).
Anyway i will share what i know about parameters passing. Keep watching.
Alain
Re: Writing $$external extensions with QLib
Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .EmmBee wrote: I have written a Qlib external called DCOPY, the 'D' standing for DATE. So, I can DCOPY "File_A" TO "File_B", and it will copy the file including the DATE. This only works on SMSQ/E. One thing I have to remember is to always use the quote marks, else it won't work.
Do you also have a variant of WCOPY that preserves the date ?
In QL Commander I use both Copy and WCopy and it would be nice to be able to preserve the date.
Re: Writing $$external extensions with QLib
I've just updated DCOPY so that it runs from the PROG_USE directory. The source is included.Andrew wrote:Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .EmmBee wrote: I have written a Qlib external called DCOPY, the 'D' standing for DATE. So, I can DCOPY "File_A" TO "File_B", and it will copy the file including the DATE. This only works on SMSQ/E. One thing I have to remember is to always use the quote marks, else it won't work.
Do you also have a variant of WCOPY that preserves the date ?
In QL Commander I use both Copy and WCopy and it would be nice to be able to preserve the date.
It does both Copy and also WCopy including recursing down any sub-directories encountered. You can also enter a pattern, as you can in DIR or WSTAT, etc.
I hope it works for you. Let me know if there are any problems.
Re: Writing $$external extensions with QLib
I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,EmmBee wrote:I've just updated DCOPY so that it runs from the PROG_USE directory. The source is included.Andrew wrote:Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .EmmBee wrote: I have written a Qlib external called DCOPY, the 'D' standing for DATE. So, I can DCOPY "File_A" TO "File_B", and it will copy the file including the DATE. This only works on SMSQ/E. One thing I have to remember is to always use the quote marks, else it won't work.
Do you also have a variant of WCOPY that preserves the date ?
In QL Commander I use both Copy and WCopy and it would be nice to be able to preserve the date.
It does both Copy and also WCopy including recursing down any sub-directories encountered. You can also enter a pattern, as you can in DIR or WSTAT, etc.
I hope it works for you. Let me know if there are any problems.
DCOPY.zip
4E75 7000
Re: Writing $$external extensions with QLib
Thank you !EmmBee wrote:I've just updated DCOPY so that it runs from the PROG_USE directory. The source is included.
It does both Copy and also WCopy including recursing down any sub-directories encountered. You can also enter a pattern, as you can in DIR or WSTAT, etc.
I hope it works for you. Let me know if there are any problems.
DCOPY.zip
Re: Writing $$external extensions with QLib
Alternately, for simple COPY you can use standard TK2 commands to reset original update date;Ralf R. wrote:I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,
oldate=FUPDT(\file_A):COPY file_A TO file_B:SET_FUPDT \file_B,oldate
(pay attention to backslash)
Alain
Re: Writing $$external extensions with QLib
This may put the version +1?HAOUI wrote:Alternately, for simple COPY you can use standard TK2 commands to reset original update date;Ralf R. wrote:I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,
oldate=FUPDT(\file_A):COPY file_A TO file_B:SET_FUPDT \file_B,oldate
(pay attention to backslash)
4E75 7000
Re: Writing $$external extensions with QLib
Usually, COPY command doesn't change the version number but if this happens in some way, you have similar TK2 commands to reset the version number;Ralf R. wrote:This may put the version +1?
oldvers=FVERS(\file_A):COPY file_A to file_B:SET_FVERS \file_B,oldvers
Alain