Multiple job name

Anything QL Software or Programming Related.
User avatar
Giorgio Garabello
Trump Card
Posts: 168
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, ITaly
Contact:

Multiple job name

Postby Giorgio Garabello » Tue Dec 05, 2017 12:21 pm

Ok, the problem is this:
in BOOT I have to launch a certain program, let's call it PIPPO a certain number of times.
Each launch will be made with a different parameter. (because the program based on the parameter will do different things.)
so in my job list will appear a number of programs all with the same name.
At a certain point I may need to close only one of these jobs, the one launched with a certain parameter ....
How can I distinguish them?
Can a job change its name independently?

sorry for my bad english.. :-(

Giorgio


User avatar
tofro
QL Wafer Drive
Posts: 1247
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Multiple job name

Postby tofro » Tue Dec 05, 2017 12:54 pm

Giorgio,

yes, a job can change its name, if it is prepared to do so. Some programs change the job name to the file that is being worked on - QD, for example will display the file being edited as part of the job name. It is, however, close to impossible to change a jobs name "from the outside", because it is only the programmer of the job that knows how much space he reserved for the name (which lives inside the job's memory), and by far the most executable programs assume a constant string and a constant length for the name - So, normally, there's just no room in the job to patch the name (and it is actually a bit complex to get the address of a job's name).

Distinguishing jobs by their name is also not a very good method - there is no guarantee at all that a job's name is unique - What's unique in the system ist its job ID.

What you can do easily, however, is to use FEX (which returns the job ID of the newly started job) instead of EX to start a job and remember the job IDs in BASIC variables (or wherever else you prefer, on a file in a ram disk, for example):

Code: Select all

100 a = FEX ("win1_progs_qd")
1000 REM Lots of program lines.....
2000 RJOB a MOD $10000,a DIV $10000,0


will do the same as

Code: Select all

100 EX "win1_progs_qd"


but save the job ID of the executable job in a and kill the job using its job ID and tag in line 2000.

Note all of this will only work on newer SMSQ/Es

Tobias


User avatar
Giorgio Garabello
Trump Card
Posts: 168
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, ITaly
Contact:

Re: Multiple job name

Postby Giorgio Garabello » Tue Dec 05, 2017 1:08 pm

tofro wrote:Giorgio,

yes, a job can change its name, if it is prepared to do so. Some programs change the job name to the file that is being worked on - QD, for example will display the file being edited as part of the job name. It is, however, close to impossible to change a jobs name "from the outside", because it is only the programmer of the job that knows how much space he reserved for the name (which lives inside the job's memory), and by far the most executable programs assume a constant string and a constant length for the name - So, normally, there's just no room in the job to patch the name (and it is actually a bit complex to get the address of a job's name).

Distinguishing jobs by their name is also not a very good method - there is no guarantee at all that a job's name is unique - What's unique in the system ist its job ID.

What you can do easily, however, is to use FEX (which returns the job ID of the newly started job) instead of EX to start a job and remember the job IDs in BASIC variables (or wherever else you prefer, on a file in a ram disk, for example):

Code: Select all

100 a = FEX ("win1_progs_qd")
1000 REM Lots of program lines.....
2000 RJOB a MOD $10000,a DIV $10000,0


will do the same as

Code: Select all

100 EX "win1_progs_qd"


but save the job ID of the executable job in a and kill the job using its job ID and tag in line 2000.

Note all of this will only work on newer SMSQ/Es

Tobias


Hello, I'm talking about a program written by me in SBasic, but I did not understand how to do .... be patient, my English sucks


User avatar
pjw
Trump Card
Posts: 246
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Multiple job name

Postby pjw » Tue Dec 05, 2017 2:56 pm

In SBASIC you could just

JOB_NAME pippo & HEX$(DATE,32)

to create a unique job name. This name can be changed in the same way while the (SBASIC) job is running. Cant remember the name length limit, although it must be more than 40+ char.

In QLiberated programs there is no documented way to change the name of the job from within the job (although Ive written a small toolkit that does exactly that). The name length limit is in the current version of QLib is, sadly, only 22 char. Hopefully this will change in the next version of QLiberator!

It should be possible to change a job's name from "outside" the job, provided you know the space available (eg 22 char for QLibed jobs).


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
User avatar
Giorgio Garabello
Trump Card
Posts: 168
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, ITaly
Contact:

Re: Multiple job name

Postby Giorgio Garabello » Tue Dec 05, 2017 2:58 pm

pjw wrote:In SBASIC you could just

JOB_NAME pippo & HEX$(DATE,32)

to create a unique job name. This name can be changed in the same way while the (SBASIC) job is running. Cant remember the name length limit, although it must be more than 40+ char.

In QLiberated programs there is no documented way to change the name of the job from within the job (although Ive written a small toolkit that does exactly that). The name length limit is in the current version of QLib is, sadly, only 22 char. Hopefully this will change in the next version of QLiberator!

It should be possible to change a job's name from "outside" the job, provided you know the space available (eg 22 char for QLibed jobs).


but job_name don't work with compiled programs....


User avatar
pjw
Trump Card
Posts: 246
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Multiple job name

Postby pjw » Tue Dec 05, 2017 2:59 pm

tofro wrote:

Code: Select all

100 a = FEX ("win1_progs_qd")
1000 REM Lots of program lines.....
2000 RJOB a MOD $10000,a DIV $10000,0

Or just

Code: Select all

100 jid = FEX ("win1_progs_qd")
1000 REM Lots of program lines.....
2000 RJOB jid,0


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
User avatar
Giorgio Garabello
Trump Card
Posts: 168
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, ITaly
Contact:

Re: Multiple job name

Postby Giorgio Garabello » Tue Dec 05, 2017 3:18 pm

sorry, I did not write all the information, I'm talking about programs written in SBASIC and compiled with QLIBERATOR


User avatar
pjw
Trump Card
Posts: 246
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Multiple job name

Postby pjw » Tue Dec 05, 2017 3:25 pm

Giorgio Garabello wrote:sorry, I did not write all the information, I'm talking about programs written in SBASIC and compiled with QLIBERATOR
You said SBASIC ;) With QLiberated programs you need my toolkit. I'll send a copy to you by email. Remember, the (undocumented) job name length limit for QLiberated programs is only 22 char.


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
User avatar
Giorgio Garabello
Trump Card
Posts: 168
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, ITaly
Contact:

Re: Multiple job name

Postby Giorgio Garabello » Tue Dec 05, 2017 3:28 pm

pjw wrote:
Giorgio Garabello wrote:sorry, I did not write all the information, I'm talking about programs written in SBASIC and compiled with QLIBERATOR
You said SBASIC ;) With QLiberated programs you need my toolkit. I'll send a copy to you by email. Remember, the (undocumented) job name length limit for QLiberated programs is only 22 char.


Sorry, my fault

Giorgio


User avatar
pjw
Trump Card
Posts: 246
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Multiple job name

Postby pjw » Tue Dec 05, 2017 4:21 pm

Alternatively, you have to "remember" the ID of each job:

Code: Select all

DIM jobIDs(20), JobPar$(20, 20): rem or whatever
jobp = 0
..
JobPar$(jobp) = <param_jobp>
jobID(jobp) = FEX(<path>&"PIPPO"; JobPar$(jobp)
jobp = jobp + 1
etc
..
job2kill = Scan(<param_n>): rem Scan JobPar$ for required parameter; ret 0 for not found
if job2kill > 0: RJOB job2kill, 0


Saving the best for last: Another way of giving a job a different name from the outside is to use EXEP or its function equivalent, FEP:

Code: Select all

jid = FEP(<path>& "Pippo"; "myparams", "pippo param1")
..
RJOB jid, 0

I hope one of these methods help..


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016

Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 1 guest