Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

/prog/ Challenge

Name: Anonymous 2010-07-30 18:10

Write a crossplatform program which works in background and switches music depending if its day or night.
Bonus points for Enterprise Features.

Name: Anonymous 2010-07-30 18:34

This is /prog/ - Programming, not /pl/ - Plumbing.

Name: Anonymous 2010-07-30 18:39

>>2
Speaking of which, has anyone read the Structure and Interpretation of Non-Newtonian Fluids?

Name: Anonymous 2010-07-30 18:42

>>3
non-newtonian
Unscientific and Ultimately Destructive

Name: Anonymous 2010-07-30 23:50

OpenConsole();
timeofday.i=0;
If ReadFile(0, "loadmusic.dat");
  Night$ = ReadString(0);
  Day$ = ReadString(0);
   Else
  PrintN("File not found: please create file `loadmusic.dat` with 2 lines-> night music file and day music file")
  End 2;
EndIf;

  If (Hour(Date()))>21 Or (Hour(Date()))<9
    PrintN("Start Night music:"+Night$);
     state=RunProgram(Night$, "", "", #PB_Program_Open)
     mode=1
  Else
    PrintN("Start Day music:"+Day$); 
    state=RunProgram(Day$, "", "", #PB_Program_Open)
         mode=0
  EndIf

  While 1=1
    If ((Hour(Date()))>21 Or  (Hour(Date()))<9)
      timeofday=1
    Else
     timeofday=0
      EndIf;
   
    If  timeofday=1 And mode=0
      KillProgram(state);
      state=RunProgram(Night$, "", "", #PB_Program_Open)
           PrintN("Switch-> Night music:"+Night$);
      mode=1;
      EndIf
      If  timeofday=0 And mode=1
        KillProgram(state);
          PrintN("Switch->Day music:"+Day$); 
      state=RunProgram(Day$, "", "", #PB_Program_Open)
      mode=0;
      EndIf
 
  Delay(60000)
Wend

Name: Anonymous 2010-07-31 0:20

>>4
Did you just call Einstein unscientific and ultimately destructive?  IHBT

Name: Anonymous 2010-07-31 6:07

Mine would be a shell script instructing Amarok over D-Bus to load a new playlist at configured times. It's ``cross-platform'' in terms of OS and architecture, but still ties you down to specific software.

I don't have any need of such a thing so I'm not going to write it. Probing Amarok via D-Bus about how it wants to load a new playlist is by far more time consuming than writing the actual code.

Name: Anonymous 2010-08-02 3:53

>>8
you're making it too complex, because you have to consider whether or not that playlist will complete in a specified amount of time
1,8>>
you're dealing with queueing and scheduling, ie, sorting queues and deciding on relative lengths of 'days' and 'music'
>>1
your solution follows, because bash is ``cross-platform'' (c.f. wikipedia)

...

IHBT

Name: Anonymous 2010-12-21 13:10

<

Name: Anonymous 2011-02-03 1:00

Don't change these.
Name: Email:
Entire Thread Thread List