Qbasicnews.com

Full Version: Help me with: A automatic task planner!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ok I work temporaraly at a hospitall, and they asked me to write this program:

Every week one of the employees has the task to be 24 hours a day availlable for technicall services. At the beginning of each year they can fill in a form, which weeks the don't are availleble.

This program must be able to read this form and automaticly fills in which employee has the task.


Here is what I did I created an array wich looks like this:
Weeks(MaxEmployees, 52)

Then The form is conferted in a data stroke wich has 53 entry's like this:

DATA 0,0,0,0,0,1,1,1,0,1,0........ etc. untill 53

A 0 is availlable and a 1 Not. The part I get stuck is to get an Output wich is an array where each emplyee gets divided. Like this:

Task(Weeks) = "EmployeeName"

I gave every Emplyee a number, but they don't want to get planned to do two weeks after eachotter so each empoyee has a variable wich hold track off how many weeks the already have to do so the one with the lesser weeks is gonna be next unless he has a 1 in his data stroke.

How do I do this is my question.

I hope you understand my englisch, its hard for me to descripe the idea I have in my mind. I also can't show you what I have so far cause the program is on my works computer and I type this at home, I'll try to post this later.
You shoud, use files.....data statements aren't very customizable when someone ahs no clue what they're doing..

Each person should have their own folder, each with a file saying when they're off, and another saying when they work..


Code:
'Registering staff:
INPUT "First name:",fname$
INPUT "Last name:",lname$

print "Creating Directories...";

folder$ = ltrim$(rtrim$(lname$)) + ltrim$(rtrim$(left$(fname$, 2)))

MKDIR "./" + folder$

print "Done"

Print "Creating Files...";

OPEN "./" + ltrim$(rtrim$(folder$)) + "/Days.Off" FOR OUTPUT AS #1
OPEN "./" + ltrim$(rtrim$(folder$)) + "/Days.On" FOR OUTPUT AS #2

CLOSE

print "Done"

END

Ug.....then jsut input into the files wahtever

Oz~
Quote:You shoud, use files.....data statements aren't very customizable when someone ahs no clue what they're doing..

I know that, the data statements where just for testing the program, if it works with data statements, itseasy to convert the program using files.

The real ploblem is how to automaticly fill in wich emplyee has to do the task for each week of the year.
check if they were on shift last, then go to the next alphabetical person....

Oz~
No that won't give them equil shifts because if one fills in he's not availlable he go's to the next alphabeticall person. Like this.

Person 1
Person 2
Person 4 <-- Because person 3 was not availlble this week.
Person 5
Person 1
etc.. <-- This way person 3 has to do lesser shifts and that woudn't be fair.

EDIT: I wanted to post my code so far but I noticed all the variable names where dutch so it would be harder for you people to understand the code, next time I try to translate the vars name and post the code as quikly as possible.
Tie a numberr_of_shifts_worked counter to each person. At the beggining of the year all counters are 0.

For each week
bubble-sort the array persons-counters in ascending order of counteers.
Then you start to check the disponibility of the persons in ascending order.
The first person that's free gets that weeks shift, and its counter is increased by 1

This should give a more or less even pattern, needing some manual fine adjustment at the end, so all people got the same working time.
I agree with Antoni.


Using this method if someone fills in for soemone they dont have to do it more then the guy that missed.
i didn't mean start at 'A', i ment start to the very next free person.

The counter wuold work vrey well.....

Oz~
I worked the counter idea out. I also added a counter that shows wich one was the last person who did its shift. So if evrybody has equil counters of shift. It chooses the person that did his shfit the earlyest. to prevent this effect.

There are 4 persons

Person 1
Person 2
Person 3
Person 4
<-- Here it chooses person 1 and not Person 4 with the second counter.
If you choose something like this...

(File would be updated monthly, so only one month is in the computer at one time...)

Code:
'Which staff member?
INPUT "First name:",fname$
INPUT "Last name:",lname$

folder$ = ltrim$(rtrim$(lname$)) + ltrim$(rtrim$(left$(fname$, 2)))

OPEN folder$ + "/Shift.wrk" FOR RANDOM AS #1

day% = 1

DO UNTIL EOF(1)

INPUT #1, info$

   SELECT CASE info$
        CASE "on"
           'Code the apprioprate counter(1) increase
        CASE "off"
           'Code the apprioprate counter(2) increase
        CASE ELSE
          'Error handler
   END SELECT          

day = day% + 1

LOOP
CLOSE

print "Done"

END
Pages: 1 2