Page 1 of 1 1
Topic Options
#207494 - 2013-07-25 11:07 PM $cdate
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
I used the command $cdate to dignify a calendar date.
for example:

 Code:
$cdate = "2009/03/01"


and then used it in the below:

 Code:
$x = 0
$FileName = Dir("$home$folder\(current month)\*.*")
  While $FileName <> "" and @ERROR = 0
   $file = "$home$folder\(current month)\$filename"
   $fdate = Substr(GetFileTime($file),1,10)
   IF $fdate > $cdate
     $attach[$x] = "$filename"
     $x = $x + 1
   ENDIF
  $FileName = Dir() ; retrieve next file


picking up files with a date after the $cdate
When I run debug, there is an error in the line with $cdate

Is there anywhere I can look at built-in variables?



Edited by Mart (2013-07-26 08:32 AM)
Edit Reason: Please use code tags when posting code.

Top
#207504 - 2013-07-26 02:50 PM Re: $cdate [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Thanks Mart - just figured out how to use the code tags!
Top
#207506 - 2013-07-26 02:58 PM Re: $cdate [Re: Karon]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
For date calculations you will need to use one of the UDFs found here on the forums... I use serialdate for all things like this.

Serialdate -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=82573

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

For your code it would be something like
 Code:
IF serialdate($fdate) > serialdate($cdate)

Top
#207511 - 2013-07-26 03:31 PM Re: $cdate [Re: Allen]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
It isn't used in an IF statement.
These are the entries I have that I need to get working:
 Code:
$cdate = "1995/03/01"

 Code:
$home = "\\server\directory"

 Code:
$thismo = @monthno -1

 Code:
$month = "12"


should I just use DIM to create the variable names?

The script was written with an kix4.20 and will not work as is for 4.63
The pc this is going to run on is windows 7 pro 32bit. The
Thanks!


Edited by Karon (2013-07-26 03:43 PM)
Edit Reason: add os version and kix version

Top
#207512 - 2013-07-26 03:39 PM Re: $cdate [Re: Karon]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Can you please post the complete script. What you are asking and what you are showing between your two posts, doesn't line up.
Top
#207513 - 2013-07-26 03:52 PM Re: $cdate [Re: Allen]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
sure! I will send the old script and the new one I am working on...
I have a different thread going for the e-mailing portion, but I can't get past the #$# variables with the new kix.

OLD SCRIPT
 Code:
;**** 
;**** 

;
; Docmailer.KIX
; mail reports to certain docs
;
;  Note :  Reads doctor info from docmailer.txt file
;

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-
;setup

$cdate = "2009/03/01"

$home = "K:\Doctor Reports\"
$setup = "\\ntserver2\mis\reports\docmailer.txt"
;$FSO = createobject("Scripting.FileSystemObject")
Dim $attach [15]

;open txt file with tab names 
IF Open(1, "$setup") = 0
$drfile = ReadLine(1)
ELSE
BEEP
? "Doc file not opened, error code: [" + @ERROR + "]"
sleep 5
EXIT
ENDIF

$thismo = @monthno -1
IF $thismo = 0
  $month = "12"
ELSE
  IF $thismo > 9
    $month = CSTR($thismo)
  ELSE
    $month = "0" + CSTR($thismo)
  ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)

;open log file
IF Open(2, "\\ntserver2\mis\reports\log$month.txt",5) = 0
  $w = WriteLine( 2 , "docmailer.kix started at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
  ELSE
  BEEP
  ? "Error opening log file: [" + @ERROR + "]"
  sleep 5
  EXIT
ENDIF


;main program loop
?"read "
sleep 2
WHILE $readerr = 0
$x = ReadLine(1)
$readerr = @ERROR
$folder = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$email = SUBSTR($x, 1, LEN($x) - INSTR($x, ","))

sleep 5 

?"folder = $folder"

$x = 0
$FileName = Dir("$home$folder\(current month)\*.*")
  While $FileName <> "" and @ERROR = 0
   $file = "$home$folder\(current month)\$filename"
   $fdate = Substr(GetFileTime($file),1,10)
   IF $fdate > $cdate
     $attach[$x] = "$filename"
     $x = $x + 1
   ENDIF
  $FileName = Dir() ; retrieve next file
LOOP


IF $attach[0] <> ""
  SendEmail ("$email", "Reports  -  !!! DO NOT REPLY !!!",
		"!!! DO NOT REPLY - EMAIL IS NOT MONITORED.  FOR ASSISTANCE CALL 657-5041 !!!",
                 $attach[0],
                 "$home$folder\(current month)\"+$attach[0],
                 $attach[1],
                 "$home$folder\(current month)\"+$attach[1],
                 $attach[2],
                 "$home$folder\(current month)\"+$attach[2],
                 $attach[3],
                 "$home$folder\(current month)\"+$attach[3],
                 $attach[4],
                 "$home$folder\(current month)\"+$attach[4],
                 $attach[5],
                 "$home$folder\(current month)\"+$attach[5],
                 $attach[6],
                 "$home$folder\(current month)\"+$attach[6],
                 $attach[7],
                 "$home$folder\(current month)\"+$attach[7],
                 $attach[8],
                 "$home$folder\(current month)\"+$attach[8],
                 $attach[9],
                 "$home$folder\(current month)\"+$attach[9],
                 $attach[10],
                 "$home$folder\(current month)\"+$attach[10],
                 $attach[11],
                 "$home$folder\(current month)\"+$attach[11],
                 $attach[12],
                 "$home$folder\(current month)\"+$attach[12],
                 $attach[13],
                 "$home$folder\(current month)\"+$attach[13],
                 $attach[14],
                 "$home$folder\(current month)\"+$attach[14])


ENDIF

ReDim $attach [15]

LOOP

$ = Close (1)

$w = WriteLine( 2 , "docmailer.kix finished at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
$w = WriteLine( 2 , "   " + Chr(13) + Chr(10) )
$ = Close (2)
RETURN





Function SendEmail ($Recip, $Subject, $Text,
							Optional $AttachmentName1, 
							Optional $AttachmentPath1,
							Optional $AttachmentName2,
							Optional $AttachmentPath2,
							Optional $AttachmentName3,
							Optional $AttachmentPath3,
							Optional $AttachmentName4,
							Optional $AttachmentPath4,
							Optional $AttachmentName5, 
							Optional $AttachmentPath5,
							Optional $AttachmentName6,
							Optional $AttachmentPath6,
							Optional $AttachmentName7,
							Optional $AttachmentPath7,
							Optional $AttachmentName8,
							Optional $AttachmentPath8,
							Optional $AttachmentName9, 
							Optional $AttachmentPath9,
							Optional $AttachmentName10,
							Optional $AttachmentPath10,
							Optional $AttachmentName11,
							Optional $AttachmentPath11,
							Optional $AttachmentName12,
							Optional $AttachmentPath12,
							Optional $AttachmentName13,
							Optional $AttachmentPath13,
							Optional $AttachmentName14,
							Optional $AttachmentPath14,
							Optional $AttachmentName15,
							Optional $AttachmentPath15)


	
	;Session.Logon now uses the default MAPI profile as found in the registry.
	
If @INWIN = 2
	; Windows 98 profile
	
	$DefaultProfile = 
		ReadValue("HKEY_CURRENT_USER\Software\Microsoft\" +
			"Windows Messaging Subsystem\Profiles", "DefaultProfile")
     
Else
     ; Windows 2000 profile
                
	$DefaultProfile = 
		ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\" +
			"CurrentVersion\Windows Messaging Subsystem\Profiles", "DefaultProfile")
EndIf
			
	$Session = CreateObject("MAPI.Session")
	$Session.Logon($DefaultProfile)
			

	;Create the core MAPI objects--Message and Recipient

	$Message = $Session.Outbox.Messages.Add
	$Recipient = $Message.Recipients.Add
	   
   
   ;Compose the message
   
   $Message.Subject = $Subject
   $Message.Text = $Text 

	
	;Translating email address so the '@' symbol doesn't confuse 
	;KiXtart as being a macro.This is better than having to remember
	;to Use '@@' in the Function argument, although either method will work.
	
	If InStr ($Recip, "<unknown:") <> 0
		
		$Recip = SubStr($Recip, 1, InStr($Recip, "<unknown:") - 1) + "@@" +  
					SubStr($Recip, InStr($Recip, "<unknown:") + 9, Len($Recip))
					
	EndIf	
	
	
	;Select recipient
	;	Note:	Recipient.Type values are as follows:
	;			1 = To
	;			2 = Cc
	;			3 = Bcc			
	
	$Recipient.Name = $Recip
	$Recipient.Type = 1
	$Recipient.Resolve

	
	;Creating attachment object only if arguments were supplied.
	
	If $AttachmentName1 <> "" AND $AttachmentPath1 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName1
    	$Attachment.Source = $AttachmentPath1
    	
        EndIf 	

	If $AttachmentName2 <> "" AND $AttachmentPath2 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName2
    	$Attachment.Source = $AttachmentPath2
    	
        EndIf 	
	If $AttachmentName3 <> "" AND $AttachmentPath3 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName3
    	$Attachment.Source = $AttachmentPath3
    	
        EndIf 	

	If $AttachmentName4 <> "" AND $AttachmentPath4 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName4
    	$Attachment.Source = $AttachmentPath4
        EndIf 

	If $AttachmentName5 <> "" AND $AttachmentPath5 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName5
    	$Attachment.Source = $AttachmentPath5
    	
        EndIf 	

	If $AttachmentName6 <> "" AND $AttachmentPath6 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName6
    	$Attachment.Source = $AttachmentPath6
    	
        EndIf 	
	If $AttachmentName7 <> "" AND $AttachmentPath7 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName7
    	$Attachment.Source = $AttachmentPath7
    	
        EndIf 	

	If $AttachmentName8 <> "" AND $AttachmentPath8 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName8
    	$Attachment.Source = $AttachmentPath8
    	
        EndIf 	

	If $AttachmentName9 <> "" AND $AttachmentPath9 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName9
    	$Attachment.Source = $AttachmentPath9
    	
        EndIf 	

	If $AttachmentName10 <> "" AND $AttachmentPath10 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName10
    	$Attachment.Source = $AttachmentPath10
    	
        EndIf 	
	If $AttachmentName11 <> "" AND $AttachmentPath11 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName11
    	$Attachment.Source = $AttachmentPath11
    	
        EndIf 	

	If $AttachmentName12 <> "" AND $AttachmentPath12 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName12
    	$Attachment.Source = $AttachmentPath12

        EndIf     

	If $AttachmentName13 <> "" AND $AttachmentPath13 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName13
    	$Attachment.Source = $AttachmentPath13
    	
        EndIf 	
	If $AttachmentName14 <> "" AND $AttachmentPath14 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName14
    	$Attachment.Source = $AttachmentPath14
    	
        EndIf 	

	If $AttachmentName15 <> "" AND $AttachmentPath15 <> ""
		
		$Attachment = $Message.Attachments.Add
    	$Attachment.Name = $AttachmentName15
    	$Attachment.Source = $AttachmentPath15

        EndIf     
   
   ;Sending the message
   
   $Message.Send
   
   $Session.DeliverNow
    
  
   
   ;Disconnecting MAPI Session
   
   $Session.Logoff
   
   
   ;Object Cleanup
   
   $Attachment = 0
   $Recipient = 0
   $Message = 0
   $Session = 0
   

EndFunction    


NEW SCRIPT

 Code:
debug
;**** 
;**** 

;
; Docmailer.KIX
; mail reports to certain docs
;
;  Note :  Reads doctor info from docmailer.txt file
;

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-
;setup


$home = "K:\Doctor Reports\"
;$FSO = createobject("Scripting.FileSystemObject")


$thismo = @monthno -1
IF $thismo = 0
  $month = "12"
ELSE
  IF $thismo > 9
    $month = CSTR($thismo)
  ELSE
    $month = "0" + CSTR($thismo)
  ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)

;open log file
IF Open(2, "\\vsclinic2\mis\reports\log$month.txt",5) = 0
  $w = WriteLine( 2 , "docmailer.kix started at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
  ELSE
  BEEP
  ? "Error opening log file: [" + @ERROR + "]"
  sleep 5
  EXIT
ENDIF


;main program loop
Break on
$Docs = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", "Docs", "Names")
$Doc = Split ($docs, "#")

For Each $Doc in $Docs
$docemail = ReadProfileString("\\vsclinic2\mis\Reports\docmailer2010.txt", $doc, "Email"\

$Root = CreateObject("Outlook.Application")
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
; 			- 2 high importance
; 			- 1 normal importance
; 			- 0 low importance
$MailItem.Subject = "Reports  -  !!! DO NOT REPLY !!! - this is a test of the new system"
$MailItem.Sender = "sccognos@@shannonhealth.org"
$MailItem.To = $Email
$MailItem.Body = "!!! TEST TEST TEST - DO NOT REPLY - EMAIL IS NOT MONITORED.  FOR ASSISTANCE CALL 657-5041 !!!"
$MailItem.Attachments.Add("$home$doc\(current month)\*.*")
$MailItem.Send
$Root = 0
Next

Top
#207514 - 2013-07-26 04:16 PM Re: $cdate [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
adding this to my watched topics..
Top
#207525 - 2013-07-27 06:32 PM Re: $cdate [Re: Karon]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
You forgot to put the "on" after debug. Kix is looking for that value and is using the first thing available, which in this case is $home or likely your $cdate. Then you are left with "Unexpected command".

 Code:
debug on
;**** 
;**** 

;
; Docmailer.KIX
; mail reports to certain docs
;
;  Note :  Reads doctor info from docmailer.txt file
;

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-
;setup


$home = "K:\Doctor Reports\"
;$FSO = createobject("Scripting.FileSystemObject")

Top
#207532 - 2013-07-29 02:50 PM Re: $cdate [Re: Allen]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Well now, that worked like a charm!!
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, 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.034 seconds in which 0.014 seconds were spent on a total of 13 queries. Zlib compression enabled.

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