Jump to content

Newbie Task Scheduler


Recommended Posts

I have a problem that bugging me all day. And also a headache. I am trying to write script

which will control recordings from the fm tuner card.

At the first place I was having problem with WINDOWS TASK SCHEDULER because I don't know

how to bring the properties windows on as it goes on with right click and then properties.

Then I had quit on Task Scheduler because I also wanted to change some data binary and that's

what this program won't allow. Anyway I decided to write my own task scheduler just to record

voice from a radio. Because I am very new at this I had run into a lot of problems. Now I don't

know what to do. Here is one of my failed attempts to make something from nothing. I tried next

step with calling the functions but after almost whole day of reading and coding I have got full screen of mistakes. Now I am stuck in the middle of nowhere. Just show me the way, I'll try the rest... (I also could post the other routine which is full of mistakes but it is hard to

understand)

$position03 = 0  ; This is a pointer which will count the lines from a log file
While 1
$position03 = $position03 + 1; pointer is now at 1
$line = FileReadLine("D:\Sys\Scripts\Radio\Schedire.txt", $position03); Get a first line from a log file
$pday = StringMid($line,1 ,1 )    ; Data at which Day of Week will start recording
If $pday = 8 Then        ; If it's set to 8 then 
$position03 = 0          ; start to read lines from a file again
EndIf
$shour = StringMid($line,3 ,2 ); Data at which hour will start recording
$smin = StringMid($line,6 ,2 ); Data at which minute will start recording
$fhour = StringMid($line,9 ,2 ); Data at which hour will stop recording
$fmin = StringMid($line,12 ,2 ); Data at which minute will stop recording
$kbps = StringMid($line,15 ,2 ); Data at which recording quality recording will be

$position02 = 37; That is counter from what column begins filename data
$position01 = 0  ; Put Counter $coun on zero
    
; Uvecavaj $position01 i $position02 sve dok ne dodjes do granicnika (") a onda uzmi $position01 da izmeri duzinu recenice
Do
$position01 = $position01 + 1; Increase pointer which measures the lenght of a filename
$position02 = $position02 + 1; Increase pointer which measures the position of a filename (in a log file)
$check = StringMid($line,$position02,1); Control every character from a filename
Until $check = Chr(34); Until that character is " . 
$name = StringMid($line,37,$position01 ); Pickup a filename from beginning (37) until the $position01 which counted the size

; Convert my day of the week to a computer understanded day of the week (sunday = 1, etc.)
Select
    Case $pday = 1
        $wday = "2"
    Case $pday = 2
        $wday = "3"
    Case $pday = 3
        $wday = "4"
    Case $pday = 4
        $wday = "5"
    Case $pday = 5
        $wday = "6"
    Case $pday = 6
        $wday = "7"
    Case $pday = 7
        $wday = "1"
    Case Else
        MsgBox(0, "", "Something Wrong With DOTW")
EndSelect

; If PC time match with any time that has been readed from a rows above, exitloop and 
; go down to configure and start recording program
    If $wday = @WDAY AND $shour = @HOUR AND $smin = @MIN Then Exitloop 
WEnd

; Here goes mouse clicking routine and a data from $wday, $shour, $smin, $fhour, $fmin, $kbps
; that I will convert into the recording program
Edited by Larry
Link to comment
Share on other sites

Ok, I have a few questions, that may lead to me being of more help.

First is Schedire.txt. Do you make this file, or is it automatically made?

Next, I see that you have a lot of functions to parse the time to start, stop, and quality.

I would sugest starting with a known easy to use string and then moving up later.

As far as some of your code, I might have a suggestion

Select
   Case $pday = 1
       $wday = "2"
   Case $pday = 2
       $wday = "3"
   Case $pday = 3
       $wday = "4"
   Case $pday = 4
       $wday = "5"
   Case $pday = 5
       $wday = "6"
   Case $pday = 6
       $wday = "7"
   Case $pday = 7
       $wday = "1"
   Case Else
       MsgBox(0, "", "Something Wrong With DOTW")
EndSelect

can be expressed like this as well:

$x=Stringsplit("2,3,4,5,6,7,1",",")
   $wday=$x[$pday]
if $pday>7 or $pday<1 then  MsgBox(0, "", "Something Wrong With DOTW")

If you could give a line from the text file Schedire.txt, it may be helpful.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Thank you for your answer very much. I have tried several combinations and none of them worked. Everything is ok with taking text from the file, but anyway here is it the end of a file:

3 22:00-06:59 Kbps: 32             "01 Name Of The File Recording"
4 23:00-06:59 Kbps: 32             "02 Name Of The File Recording"
5 23:30-06:59 Kbps: 32             "04 Name Of The File Recording"
8

First character representing day of the week, then separator, and then 2 characters for starting hour, and then separator, and starting minute, separator, finishing hour, separator, finishing minute, separator and written "Kbps: " just to look better, and then some empty data which will be added later in a code, and then name of the file that will be recorded. Main problem was in this:

$line = FileReadLine("D:\Sys\Scripts\Radio\Schedire.txt", $position03)
$pday = StringMid($line,1 ,1 )
If $pday = 8 Then
$position03 = 0

I have inserted some msgbox line like:

MsgBox(4096,"", $position03, 1)

So I knew what was going on with $position03. FileReadLine would read all lines and when it came to the end $position03 was = 01 and it won't go another loop. I know that this is not an answer because it would be bad for HDD to read from a file all the time. Then I tried to do something like this:

$line = FileReadLine("D:\Sys\Scripts\Radio\Schedire.txt", $position03)
If @error = -1 Then $position03 = 0
EndIf

An the same thing happened. Anyway this is not the way to work with files. I need to code schedule script which will be up and running all the time. So I guess it would be nice to put data in the memory and to be checked as variable. And then just a Functions to Call to execute a program, set all parameters right (I coded that right - I checked), and to stop recording after some time (Not coded but very simple, just have to check clock at that time and compare with one that would be readed from a file as variable). No problem with that at all. Main problem is which way is the best to get main data, and to be checked and not to take too much processor time... Help me with this, please. I need just a pointers and, maybe, just a small example... How to get infinitive loops and to back safely from executing recording into that checking loop again...

Link to comment
Share on other sites

Ok, this should get you started:

$file="Schedire.txt"
$linenum=0
while 1
$linenum=$linenum+1
$line = Stringsplit(FileReadLine($file,$linenum)," ")
if UBound($line)<3 then 
$linenum=$linenum-1
sleep(1000)
continueloop
endif
$x=Stringsplit("2,3,4,5,6,7,1",",")
  $wday=$x[$line[1]]
if $wday>7 or $wday<1 then  MsgBox(0, "", "Something Wrong With DOTW")
$hour=Stringleft($line[2],2)
$min=stringmid($line[2],4,2)
msgbox(1,"Info for you","Day="& $wday &@crlf & "Hour="&$hour & @crlf & "Min="& $min)
wend

It reads your lines, and displays some of the variables, I just gave examples so that you could learn a bit of it.

When it gets to a line with only one number or so, it waits a second, and then tries to read it again.

You can set up an INI file to record the last line, and just start from there if you like. Those are pretty well documented in the help file.

Well give it a shot and if you have problems, come on back.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Great! Thank You Very Much! You gave me a couple of pointers and helped me a lot

to solve my problem and to learn something new. I have been stuck and lost.

I haven't been able to reply sooner because I had to code and solve all problems

and then see if I have anything more to ask.

I am still unfamiliar with many things using autoit but I learn more from day to day.

The other great thing is that "Schedire.txt" is loaded in memory only the first

time so no HDD is involved anymore. I tried that by running a script and then

erasing the file. Nothing happened. Ok, now I will move further to finish a script.

And again thanks for helping me out when I had hard time.

$file="D:\Sys\Scripts\Radio\Schedule2.txt"
$linenum=0
while 1
$linenum=$linenum+1
$line = Stringsplit(FileReadLine($file,$linenum),",-`:*"); I used ",-`:*" as delimiters thanks on that
if UBound($line)<5 then
$linenum=$linenum-1
sleep(10000)                              ; Guess it is better to sleep more than to run trough code?
continueloop
endif
$x=Stringsplit("2,3,4,5,6,7,1",",")
 $wday=$x[$line[1]]
if $line[1]>7 or $line[1]<1 then  MsgBox(0, "", "Something Wrong With DOTW")

$shour=Stringleft($line[4],2)
$smin=Stringleft($line[5],2)
$ehour=Stringleft($line[6],2)
$emin=Stringleft($line[7],2)
$kbps=Stringleft($line[9],2)
$hz=Stringleft($line[10],2)
$name=Stringleft($line[20],StringLen($line[20])); This one I solved myself...  Is there better way?

#cs
msgbox(1,"Info for you","day=" & $wday & "shour=" & $shour & "smin=" & $smin & "ehour=" & $ehour & "emin=" & $emin)
msgbox(1,"Info for you","kbps=" & $kbps & "hz=" & $hz & "name=" & $name)
#ce
wend

Part of Schedule2.txt:

1`1`2`00:00-06:59`099.50Mhz`32`00`00`00`00`00`00`00`00`00`00 *Voice Of America TGR*
1`1`1`07:00-07:29`095.30Mhz`32`00`00`00`00`00`00`00`00`00`00 *RB1 Good Morning Kids*
1`1`1`09:30-10:59`092.50Mhz`32`00`00`00`00`00`00`00`00`00`00 *Test B92 Forefinger*
1`1`1`11:00-11:59`095.30Mhz`32`00`00`00`00`00`00`00`00`00`00 *RB1 Hull on Mondays*
1`1`1`13:00-13:59`097.60Mhz`32`00`00`00`00`00`00`00`00`00`00 *RB2 Guest on RB2*
Link to comment
Share on other sites

  • Developers

$name=Stringleft($line[20],StringLen($line[20])); This one I solved myself...  Is there better way?
What about just using $name=$line[20] ?

You are copying the whole string with your statement...

Think this is the same for :

$shour=$line[4]

$smin=$line[5]

etc..

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...