Page 2 of 2 <12
Topic Options
#171099 - 2006-12-06 01:46 PM Re: Directory creation based on date issue [Re: Pax]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
If you don't fix the date string to include leading zeros as Allen suggested, you won't be able to tell the difference betweeen 2007121 (January 21) and 2007121 (December 1), assuming you keep your archives that long. Also, it makes the dates all 8 char strings, not something between 6 and 8, which makes sorting easier.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171101 - 2006-12-06 02:09 PM Re: Directory creation based on date issue [Re: Glenn Barnas]
Pax Offline
Getting the hang of it

Registered: 2006-12-01
Posts: 51
Originally Posted By: Glenn Barnas
If you don't fix the date string to include leading zeros as Alan suggested, you won't be able to tell the difference betweeen 2007121 (January 21) and 2007121 (December 1), assuming you keep your archives that long. Also, it makes the dates all 8 char strings, not something between 6 and 8, which makes sorting easier.

Glenn
Hey Glenn,

I've taken the script NTDOC (Is this Alan?) and he redefined the $Archive value correctly, and this value is used to create the directory and to move, create and expand the files correctly.

We are only keeping the files for 3 months, but since the issue is resolved, it should not pose a problem.

Pax

Top
#171133 - 2006-12-06 08:02 PM Re: Directory creation based on date issue [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Glenn,

I gave him this code to use.

PHP:
Dim $Archive $Archive = Trim(Join(Split(@DATE,'/'),'-'))+'_'+Trim(Join(Split(@TIME,':'),'')) 'Archive Date for var is: ' + $Archive ?


On my system the DATE is 2 character even for months 1 - 9

.

Top
#171153 - 2006-12-07 01:05 AM Re: Directory creation based on date issue [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Yeah, understood, but I didn't see anyone give reasons why the date format is important. Allen came close with his example, but - again - examples are better when you describe WHY you do something a certain way, especially in the scripts or this Starters forum. Other people will read these messages and learn, too, so - it's not just Pax who will benefit.

Just my (not so humble) opinion. ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171154 - 2006-12-07 01:17 AM Re: Directory creation based on date issue [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Who is this Alan character?
Top
#171155 - 2006-12-07 01:28 AM Re: Directory creation based on date issue [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Looks like we might have at least seven members that might be named Alan.
http://www.kixtart.org/forums/ubbthreads.php?ubb=showmembers&sb=1&like=a&page=7

Maybe Ron's middle name is Alan.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171156 - 2006-12-07 02:35 AM Re: Directory creation based on date issue [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Okay Glenn - here is some explanation of what I'm doing in the code per your suggestion.



@DATE
Returns this for me: 2006/12/06
@TIME
Returns this for me: 17:24:16


So we use the function SPLIT and assign it to our variable (in this case $Archive)
Quote:

SPLIT
Returns a zero-based, one-dimensional array containing a specified number of substrings.
Syntax: Split (“string”, “delimiter”, count)


We use the delimiter of / in the code: Split(@DATE,'/') which basically removes the /

We then use the JOIN function to replace the / with a - (because a / on Windows is not a valid file/folder name)
Quote:

JOIN
Creates a string by concatenating the elements of an array.
Syntax: Join (array, “delimiter”, count)


Then to get the TIME we do similar but this time we use the : as the delimiter for SPLIT and then replace it with nothing.
If we did not use the JOIN function then our var would still contain an array which is not as easily used for what we're trying to do here.
I use the +'_'+ to place the _ character between the DATE and TIME

For my system I have the dates display 2 characters for all months and days so this coding works well for me.
If your system returns single characters for months, or days 1 - 9 then you should be able to manage that in the Control Panel settings of your system.

Although according to the manual the KiXtart @DATE will return the date in this format every time: Date (in the format YYYY/MM/DD)



.


Edited by NTDOC (2006-12-07 02:43 AM)

Top
#171158 - 2006-12-07 04:24 AM Re: Directory creation based on date issue [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
What on earth are you talking about, Allen? ;\)
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171159 - 2006-12-07 04:30 AM Re: Directory creation based on date issue [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Sweet, Doc!

The original code Pax used employed the individual date macros, which don't have leading zeros. That's why Allen padded the string with leading zeros and then took the rightmost 2 chars - changing "1" to "01", for example.

By using the @DATE with Join(Split()) functions, you already have 2-digit values for month and day. Once again, ya illustrate that there's more than one (right) way to do things. \:\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171160 - 2006-12-07 06:22 AM Re: Directory creation based on date issue [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Originally Posted By: Glenn Barnas
What on earth are you talking about, Allen? ;\)


hmmm... missed this one? ;\)
http://www.kixtart.org/forums/ubbthreads...true#Post170560

{edit: Ack! its worse than I thought ;\) }
http://www.kixtart.org/forums/ubbthreads...true#Post133850


Edited by Allen (2006-12-07 06:28 AM)

Top
#171161 - 2006-12-07 06:31 AM Re: Directory creation based on date issue [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol.
_________________________
!

download KiXnet

Top
#171162 - 2006-12-07 06:49 AM Re: Directory creation based on date issue [Re: Lonkero]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Didn't Pax call DOC Alan?
Quote:
I've taken the script NTDOC (Is this Alan?)

Will the real Alan please step forward?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171163 - 2006-12-07 06:53 AM Re: Directory creation based on date issue [Re: Les]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
All these name confusions... How... er, Rich... er, Les... er, Alan? I just can't work another "er" into Alan. \:\(
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171165 - 2006-12-07 11:16 AM Re: Directory creation based on date issue [Re: Les]
Pax Offline
Getting the hang of it

Registered: 2006-12-01
Posts: 51
Would it be possible to steer clear of which Alan/Allen/Allan/Alen is which for 2.5 seconds, and I was getting confused as to where this thread was going?? I understand what NTDOC did, but yes explaining it for the masses who don't understand what I do now is a great benefit for this thread.

Back to post #171095
Quote:
I just had another thought on your suggestion about the WRITELINEs I seem to be doing everywhere.

Would it be a better choice to open the logfile, and immediately below it use
PHP:
RedirectOutput($ARCHIVELOG)

and remove the WRITELINE commands? This would mean I could capture the output from Blat, RAR and UNRAR directly to the log file, as I think this would be served well in the file.

The benefits would be that if there are problems, then I can just comment out that line and see it on screen running it manually. Also the script would be smaller and easier to diagnose if problem turn up instead of having screen output and log file output seperately?

Ideas?

Pax


I got a comment confirming that RedirectOutput does mean nothing will appear on the console, which is fine as this will run as a scheduled task, BUT, is this the better method than having comments and errors echoing to screen, and again writing them to the file.

It would just down on the script size, and possible mean less errors as there is less code for me to leave out a rogue ",),; mark??

Pax

EDIT: Answered my own questions partially by trying it, but I still have the problem with redirecting RAR and UNRAR output as using >> tell me that it doesn't understand the command, so I'm exploring using the option -ierr which re-directs to STDERR.

It will need refining more, but I'll post here when I am happy enough for it to go into production.

Because I am trying to email the log file using blat, I have found that I have to do a RedirectOutput("") before emailing the file to close the file, otherwise the file cannot be accessed to it being help open. It is an issue with blat, but at least I can work around it.


Edited by Pax (2006-12-07 02:19 PM)

Top
#171173 - 2006-12-07 03:20 PM Re: Directory creation based on date issue [Re: Pax]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
the @-sign in strings should not be doubled if NoMacrosInStrings is On
Code:
...
$SO=SetOption('NoMacrosInStrings','On')
...
$Sender = 'sender@emailserver.net'
$SupportEmail = 'support@emailserver.net'
$EmailAddress = 'recipient@emailserver.net'
...

Top
#171177 - 2006-12-07 04:06 PM Re: Directory creation based on date issue [Re: Witto]
Pax Offline
Getting the hang of it

Registered: 2006-12-01
Posts: 51
Originally Posted By: Witto
the @-sign in strings should not be doubled if NoMacrosInStrings is On

Yeah I know, was part of me "testing" NTDOC's script and integrating it into my original.

I found another few syntax issues throughout which I've corrected \:\)

Thanks for pointing that out though,

Pax

Top
#171178 - 2006-12-07 04:32 PM Re: Directory creation based on date issue [Re: Pax]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
wow. A bunch of replies. Still
Code:
Shell ("monkey")


????
reeemove the brackets. it's shell "monkey" ;\)

(
Code:
Shell "monkey"
)

Second, what's up with using the php-enclosures? and third, what's up with not cathing the linebreaks- thus copy'n'paste turns into a mess *_*


Edited by Björn (2006-12-07 04:46 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#171192 - 2006-12-07 09:12 PM Re: Directory creation based on date issue [Re: Pax]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
1. I'm the one using the PHP tag a lot as it looks and formats nice on the board.

2. I would use store what I want to see in a log file to VARS then write at the end.

3. In order to see the output from RAR you would need to launch from %comspec% first and then make sure you end the RAR command, then redirect.

4. Sorry for the "syntax" errors, but I did not write the whole script as though it were going to be in production by myself.

5. Sorry to go "off topic" but pretty much it was assumed your concerns were answered and the rest was in good fun (this is not a business and all are here as volunteers).

6. The explanation is "ON TOPIC" regardless of other noise in the post.

7. If you have other questions please let us know.

8. LOOSEN up bit - you got a lot of good free advice that would be difficult to come by without the efforts of other members on the board.

9. NTDOC should also loosen up a bit - sorry but your tone sounded a bit harsh and struck a cord with me I suppose. Sorry

10. HAPPY HOLIDAYS


.

Top
#171194 - 2006-12-07 09:37 PM Re: Directory creation based on date issue [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Allen,

My deepest, most humble apology.

Gleeen
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171282 - 2006-12-09 09:35 PM Re: Directory creation based on date issue [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
No apologies necesary... just messin with ya.

Take care Glyn

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.076 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.

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