Page 2 of 3 <123>
Topic Options
#110981 - 2003-12-31 03:54 PM Re: ScheduleTask - Array problem
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Awesome...Im glad it worked for you. Let us know if you have any problems when you get back in the office on the 5th. Hope you enjoy your vacation.
Top
#110982 - 2003-12-31 04:14 PM Re: ScheduleTask - Array problem
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

When there are longlines in the code I confess, I'm guilty but please don't call the Police....




This is not the catholic church here. You cannot knowingly sin on Saturday with the intention of confessing on Sunday and expect to have your sins absolved.

BTW, that long line would be very easy to break into shorter ones without breaking the code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#110983 - 2004-01-01 03:08 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
LOL.. I'm a catholic...
_________________________
Co


Top
#110984 - 2004-01-02 03:00 AM Re: ScheduleTask - Array problem
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
ScheduleTask() has already been updated to allow both YYYY/MM/DD and MM/DD/YYYY date inputs.

I'll start making a new DateTimeMath() UDF that will allow more complex date-time manipulations in addition to just calculating the difference between two dates or times. I already have a couple of ideas for this, but it might take me a week or two.
_________________________
There are two types of vessels, submarines and targets.

Top
#110985 - 2004-01-02 11:15 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Thanks Jens
_________________________
Co


Top
#110986 - 2004-01-05 11:03 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Shane, Jens,

At work it works great. I didn't changed the UDF's since I posted the full script. Next step is to update the ScheduleTask() UDF.

Code:
 
For Each $comp In $computers

; filter
;------------------------------
;$os = osid($comp)
;
;If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($comp,"comp")<>0


; Date /Time
;------------------------------
$time=serialtime(serialtime($time)+serialtime($timediff))
$day=Val(Split($time,':')[0])
$hour=Split($time,':')[1]
$minute=Split($time,':')[2]
$time=$hour+':'+$minute
If $time='24:00'
$time='00:00'
$date=DateMath($date, 1)
EndIf
If $day>0
$date=DateMath($date, $day)
EndIf

; Date Format
;------------
$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]


; Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$d+' at '+$time
$rc=scheduletask($name, $comp, $d, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR

Next



There was a small problem at 24:00
Quote:


Task will be scheduled on comp1 on 01/05/2004 at 24:00
Error 1 - Incorrect function.

Task will be scheduled on comp2 on 01/06/2004 at 00:30
Error 0 - The operation completed successfully.





I modified the script with this peace of code:
Code:

If $time='24:00'
$time='00:00'
$date=DateMath($date, 1)
EndIf



Problem solved:
Quote:


Task will be scheduled on comp1 on 01/06/2004 at 00:00
Error 0 - The operation completed successfully.

Task will be scheduled on comp2 on 01/06/2004 at 00:30
Error 0 - The operation completed successfully.






Thanks guy's!
_________________________
Co


Top
#110987 - 2004-01-05 12:46 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Jens,

I have updated the script with the latest version of ScheduleTask (). It gives an error 87:

Quote:


Task will be scheduled on comp1 on 2004/01/05 at 23:58
Error 87 - The parameter is incorrect.

Task will be scheduled on comp2 on 2004/01/06 at 00:28
Error 87 - The parameter is incorrect.





I have changed $d in $date and remmed out d$:
Code:

For Each $comp In $computers

; filter
;------------------------------
;$os = osid($comp)
;
;If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($comp,"comp")<>0


; Date /Time
;------------------------------
$time=serialtime(serialtime($time)+serialtime($timediff))
$day=Val(Split($time,':')[0])
$hour=Split($time,':')[1]
$minute=Split($time,':')[2]
$time=$hour+':'+$minute
If $time='24:00'
$time='00:00'
$date=DateMath($date, 1)
EndIf
If $day>0
$date=DateMath($date, $day)
EndIf

; Date Format
;------------
;$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]


; Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$date+' at '+$time
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR

Next





Edited by Co (2004-01-05 12:49 PM)
_________________________
Co


Top
#110988 - 2004-01-05 07:42 PM Re: ScheduleTask - Array problem
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I dont see $date getting defined if it is not over a day...Maybe I missed something though.
Top
#110989 - 2004-01-05 07:43 PM Re: ScheduleTask - Array problem
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Maybe...

Code:
If $day>0		 
$date=DateMath($date, $day)
EndIf



Should be...

Code:
If $day>0		 
$date=DateMath($date, $day)
Else
$date=@date
EndIf


Top
#110990 - 2004-01-06 08:55 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Shane,

Sorry, The only code I showed is the FOR NEXT loop because all other parts of the script doesn't changed. I had to let you know...

Jens modified the ScheduleTask(). He added this code to the UDF:
Code:

select
case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case left($date,3)='\'
; valid format
case left($date,5)='\'
; reformat date
$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]
case 1
exit 87
endselect



That's why I remmed out $d(See the full script some topics ago) and changed $d in $date.
Code:

$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]

;Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$d+' at '+$time
$rc=scheduletask($name, $comp, $d, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR



Code:

;$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]

;Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$date+' at '+$time
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR




Edited by Co (2004-01-06 09:15 AM)
_________________________
Co


Top
#110991 - 2004-01-06 09:13 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Shane,

I'm not sure this is what you meant with your last post:

Replace:
Code:
  
If $time='24:00'
$time='00:00'
$date=DateMath($date, 1)
EndIf
If $day>0
$date=DateMath($date, $day)
EndIf



for:

Code:

If $day>0
$date=DateMath($date, $day)
Else
$date=@date
EndIf



unfortunately, It doesn't work

Quote:


Task will be scheduled on comp1 on 01/06/2004 at 24:00
Error 1 - Incorrect function.

Task will be scheduled on comp2 on 01/07/2004 at 00:30
Error 0 - The operation completed successfully.










_________________________
Co


Top
#110992 - 2004-01-06 09:48 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
MMMM,

There is a difference between the added code in ScheduleTask and $d:

ScheduleTask:
Code:

$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]



$d:
Code:

$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]



I have changed all \ in / but there is still an error 87

...I give up, I have a working script with the old version of ScheduleTask and variable $d...


Edited by Co (2004-01-06 10:11 AM)
_________________________
Co


Top
#110993 - 2004-01-06 05:56 PM Re: ScheduleTask - Array problem
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
You're right...The case select portion that Jens added was a little off. The usage of the LEFT function was wrong.

Try Replacing the following...

Code:
select

case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case left($date,3)='\'
; valid format
case left($date,5)='\'
; reformat date
$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]
case 1
exit 87
endselect



With this...

Code:
select 

case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case right(left($date,3),1)='/'
; valid format
case right(left($date,5),1)='/'
; reformat date
$date=split($date,'/')
$date=$date[1]+'/'+$date[2]+'/'+$date[0]
case 1
exit 87
endselect


Top
#110994 - 2004-01-06 06:41 PM Re: ScheduleTask - Array problem
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Darn, that happens when you try to improve an UDF while feeding a baby and not testing it. I'll correct that at once with a correctly used SUBSTR().
_________________________
There are two types of vessels, submarines and targets.

Top
#110995 - 2004-01-06 10:15 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Shane,

I did but there was still an error 87...
_________________________
Co


Top
#110996 - 2004-01-06 10:16 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Jens,

Lol, I know how it feels... the second one is on his way..
_________________________
Co


Top
#110997 - 2004-01-06 10:18 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Sorry Shane your code is different.. I'll test it tommorow..
_________________________
Co


Top
#110998 - 2004-01-07 10:44 AM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Shane,

FANTASTIC!!!

Quote:


Task will be scheduled on comp1 on 2004/01/07 at 23:58
Error 0 - The operation completed successfully.

Task will be scheduled on comp2 on 2004/01/08 at 00:28
Error 0 - The operation completed successfully.





I replaced the Select..Endselect Jens added to Scheduletask() with your code . deleted $d and changed $d in $date in other parts of the code and it now works perfect.

Thanks!


Edited by Co (2004-01-07 10:52 AM)
_________________________
Co


Top
#110999 - 2004-01-07 03:51 PM Re: ScheduleTask - Array problem
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
BTW, I already corrected the ScheduleTask() UDF with a corrected version utilizing SUBSTR().
_________________________
There are two types of vessels, submarines and targets.

Top
#111000 - 2004-01-07 07:14 PM Re: ScheduleTask - Array problem
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Jens,

I didn't tested it but I think you have to replace the backslashes with slashes since the date format must be MM/DD/YYYY...

Code:

case substr($date,3,1)='\'
; valid format
case substr($date,5,1)='\'
; reformat date
$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]



Must be...

Code:

case substr($date,3,1)='/'
; valid format
case substr($date,5,1)='/'
; reformat date
$date=split($date,'/')
$date=$date[1]+'/'+$date[2]+'/'+$date[0]



Feeding the baby again.. or did you had a very short and broken night
_________________________
Co


Top
Page 2 of 3 <123>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.115 seconds in which 0.068 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org