Multiple job name

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

Multiple job name

Post by Giorgio Garabello »

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
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Multiple job name

Post by tofro »

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


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Giorgio Garabello
Gold Card
Posts: 277
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

Re: Multiple job name

Post by Giorgio Garabello »

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
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Multiple job name

Post by pjw »

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
dont be happy. worry
- ?
User avatar
Giorgio Garabello
Gold Card
Posts: 277
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

Re: Multiple job name

Post by Giorgio Garabello »

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
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Multiple job name

Post by pjw »

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
dont be happy. worry
- ?
User avatar
Giorgio Garabello
Gold Card
Posts: 277
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

Re: Multiple job name

Post by Giorgio Garabello »

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


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Multiple job name

Post by pjw »

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
dont be happy. worry
- ?
User avatar
Giorgio Garabello
Gold Card
Posts: 277
Joined: Tue Jun 30, 2015 8:39 am
Location: Turin, Italy
Contact:

Re: Multiple job name

Post by Giorgio Garabello »

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
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Multiple job name

Post by pjw »

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
dont be happy. worry
- ?
Post Reply