Skip to Content
It is currently July 16th, 2019, 12:07 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 1st, 2019, 5:53 pm 
Offline
New User
New User

Joined: October 28th, 2015, 10:44 pm
Posts: 12
I am having trouble using DayOfWeek
I want to (somehow) put the DayOfWeek (1-7 or Sun-Sat) in the Queue.AddFile path.

here's the code I'm working on:
Code:
PAL.LockExecution;
var filename : String;
filename := FormatDateTime('day-HH',Now)+'FILENAME.mp3';
WriteLn (filename);
Queue.AddFile('C:\Users\SAM-Broadcaster\PATH\'+filename, ipBottom);
PAL.UnlockExecution;


right now it returns something like this:
1a19-17FILE.mp3

'day' returns 1a19

and I need something more like this:
MONDAY-17FILE.mp3
or
MON-17FILE.mp3
or
2-17FILE.mp3 (PREFERRED FORMAT)

the manual says" "The days of the week are stored in constant values you can use. Sunday = 1 to Saturday = 7."
but I can't find a usable mask for a day of a week. What am I missing?

Can anyone help me? Please?


Top
 Profile  
Reply with quote  
PostPosted: February 2nd, 2019, 1:20 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7860
Location: Aachen (Germany)
You're not using DayOfWeek, but FormatDateTime.

Your format string is this:
Code:
day-hh

If you look at the documentation of FormatDateTime and the Date-Time format strings, you'll probably see your problem:
d stands for the day number without leading zeroes, hh for hours with leading zeroes.
The a character is a bit more complicated: It's doing two things at once. First it will turn the number for h or hh into it's 12-hour-clock counterpart (if that h/hh is coming BEFORE the a/p symbol). And second it will print either a or p in place of the a character depending on whether the time is in the first or last 12 hours of the day.
Apparently the documentation has an error in that the single y also works for 2 digit years.

Right now it's 20:10 on the 2nd of February here, so the above format string will turn into:
Code:
2p19-20


If you'd like to stick with the FormatDateTime, you must use either:
Code:
ddd-hh

or
Code:
dddd-hh


With 3 ds giving you the short version of the weekday in your current locale and 4 ds giving you the long version of the weekday in your current locale.

If you want to add literal characters in your format string that should not be replaced, enclose them in double quotes.

To get the numerical representation of the weekday, use the DayOfWeek function, combine it with IntToStr and concatenate it with your formatted string.
Code:
datestring := IntToStr(DayOfWeek(Now)) + '-' + FormatDateTime('hh');

This would result in 7-20 being stored in the datestring variable, because for some stupid reason Pascal / Delphi / PAL is considering the week to start on Sundays.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: February 2nd, 2019, 8:06 pm 
Offline
New User
New User

Joined: October 28th, 2015, 10:44 pm
Posts: 12
Hi Mastacheata,

BIG thanks for the extensive explanation.

What documentation/manual are you referring to? I'm only using those two:
http://support.spacialaudio.com/wiki/PAL
and https://support.spacial.com/hc/en-us/se ... -Scripting.

Yesterday I did some workaround in the script to make it work (it's not the cutest one but does the job:-) )
Code:
PAL.LockExecution;
var filename : String;
filename := FormatDateTime('HH',Now)+'-FILENAME.mp3';

//----------------------

if DayOfWeek(Now) = Monday then
begin
WriteLn ('Monday');
WriteLn (filename);
Queue.AddFile('C:\DRIVE\Reklamy\1-MON-'+filename, ipBottom);
end;
if DayOfWeek(Now) = Tuesday then
begin
WriteLn ('Tuesday');
WriteLn (filename);
Queue.AddFile('C:\DRIVE\Reklamy\2-TUE-'+filename, ipBottom);
end;
if DayOfWeek(Now) = Wednesday then
begin
WriteLn ('Wednesday');
WriteLn (filename);
Queue.AddFile('C:\DRIVE\Reklamy\3-WED-'+filename, ipBottom);
end;
if DayOfWeek(Now) = Thursday then
begin
WriteLn ('Thursday');
WriteLn (filename);
Queue.AddFile('C:\DRIVE\Reklamy\4-THU-'+filename, ipBottom);
end;
if DayOfWeek(Now) = Friday then
begin
WriteLn ('Friday');
WriteLn (filename);
Queue.AddFile('C:\DRIVE\Reklamy\5-FRI-'+filename, ipBottom);
end;
PAL.UnlockExecution;


In your line (example) should the datestring be declared as variable of string type?
datestring := IntToStr(DayOfWeek(Now)) + '-' + FormatDateTime('hh');

BIG THANKS


Top
 Profile  
Reply with quote  
PostPosted: February 3rd, 2019, 5:04 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7860
Location: Aachen (Germany)
adam2410 wrote:
What documentation/manual are you referring to?

Help -> PAL Scripting Reference

adam2410 wrote:
In your line (example) should the datestring be declared as variable of string type?
datestring := IntToStr(DayOfWeek(Now)) + '-' + FormatDateTime('hh');

Yes, otherwise you'd get an error for bad type. (DayOfWeek will always return a number and is converted to a string using IntToStr - Note: Converting to string only changes the internal datatype, not the actual value. It's still 1-7, not a textual representation of the weekday.)

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: February 3rd, 2019, 1:55 pm 
Offline
New User
New User

Joined: October 28th, 2015, 10:44 pm
Posts: 12
When I was searching for the date/time masking options for FormatDateTime I actually never used PAL Scripting reference - until today :-)

IT'S ALL IN THERE - BIG THANKS !!!

so I got:

Code:
PAL.LockExecution;
var filename : String;
filename := FormatDateTime('DDD-HH',Now)+'-FILE.mp3';
WriteLn (filename);
Queue.AddFile('C:\Users\SAM-Broadcaster\PATH\'+filename, ipBottom);
PAL.UnlockExecution;


or another using IntToStr(DayOfWeek(Now))

Code:
PAL.LockExecution;
var datestring : String;
datestring := IntToStr(DayOfWeek(Now)) + '-' + FormatDateTime('hh',Now)+'-FILE.mp3';
WriteLn (datestring);
Queue.AddFile('C:\Users\SAM-Broadcaster\PATH\'+datestring, ipBottom);
PAL.UnlockExecution;


Top
 Profile  
Reply with quote  
PostPosted: February 4th, 2019, 9:42 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7860
Location: Aachen (Germany)
adam2410 wrote:
IT'S ALL IN THERE - BIG THANKS !!!

Sometimes the good things lie so close you can't see them :D

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group