Writing $$external extensions with QLib

Anything QL Software or Programming Related.
HAOUI
Bent Pin Expansion Port
Posts: 89
Joined: Tue Dec 14, 2010 2:17 pm

Writing $$external extensions with QLib

Post by HAOUI »

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.


EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Writing $$external extensions with QLib

Post by EmmBee »

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.
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 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.


HAOUI
Bent Pin Expansion Port
Posts: 89
Joined: Tue Dec 14, 2010 2:17 pm

Re: Writing $$external extensions with QLib

Post by HAOUI »

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.
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.
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.
I totaly agree. I don't like that COPY modify date of the file while it has not been modified.
Backup option in QPAC2 does not modify date but there is no equivalent command.
One thing I have to remember is to always use the quote marks, else it won't work.
Passing name paramaters to $$external is a real cavity especially with PARNAM$() and PARSTR$() FUNCtions not working under QLIB.
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


User avatar
Andrew
Aurora
Posts: 794
Joined: Tue Jul 17, 2018 9:10 pm

Re: Writing $$external extensions with QLib

Post by Andrew »

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.
Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .
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.


EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Writing $$external extensions with QLib

Post by EmmBee »

Andrew wrote:
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.
Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .
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.
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
(16.06 KiB) Downloaded 112 times


User avatar
RalfR
Aurora
Posts: 872
Joined: Fri Jun 15, 2018 8:58 pm

Re: Writing $$external extensions with QLib

Post by RalfR »

EmmBee wrote:
Andrew wrote:
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.
Please, can you publish the DCOPY ? I would like to use it in QLCommander instead of Copy .
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.
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
I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,


4E75 7000
User avatar
Andrew
Aurora
Posts: 794
Joined: Tue Jul 17, 2018 9:10 pm

Re: Writing $$external extensions with QLib

Post by Andrew »

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
Thank you !


HAOUI
Bent Pin Expansion Port
Posts: 89
Joined: Tue Dec 14, 2010 2:17 pm

Re: Writing $$external extensions with QLib

Post by HAOUI »

Ralf R. wrote:I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,
Alternately, for simple COPY you can use standard TK2 commands to reset original update date;

oldate=FUPDT(\file_A):COPY file_A TO file_B:SET_FUPDT \file_B,oldate

(pay attention to backslash)

Alain


User avatar
RalfR
Aurora
Posts: 872
Joined: Fri Jun 15, 2018 8:58 pm

Re: Writing $$external extensions with QLib

Post by RalfR »

HAOUI wrote:
Ralf R. wrote:I think "SET_HEAD" and "GET_HEAD" from SG are quite good to preserve the dates,
Alternately, for simple COPY you can use standard TK2 commands to reset original update date;

oldate=FUPDT(\file_A):COPY file_A TO file_B:SET_FUPDT \file_B,oldate

(pay attention to backslash)
This may put the version +1?


4E75 7000
HAOUI
Bent Pin Expansion Port
Posts: 89
Joined: Tue Dec 14, 2010 2:17 pm

Re: Writing $$external extensions with QLib

Post by HAOUI »

Ralf R. wrote:This may put the version +1?
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;

oldvers=FVERS(\file_A):COPY file_A to file_B:SET_FVERS \file_B,oldvers

Alain


Post Reply