Cart Player Loop Status

The scripting system uses the exact same data types as the original code. There is no “dedicated data types for scripting”. All the types I declare internally in the original source code are - identically - available to scripting too. This is because the scripting code is generated from the regular source code using a tool called “psconv” (part of the RemObjects Pascal Script package).

This is the cool thing about the script system - through the psconv tool, I can expose the complete internal interface of mAirList to scripts without writing a single line of code.

I agree that the fake state thing is not a very “beautiful” solution. But a very efficient one for the internal implementation. Unfortunately, due to the scripting system, this implementation detail is exposed to the user.

OK, I understand the points now. that makes perfectly sense to me. No one would have done it otherwise. And that is by far more efficient than duplicating things.

Coming back to my problem with the timer. Would it be possible to use the OnTimer object or is it completely broken in V3?

regards:
-Serge-

It’s completely broken at the moment. I will try to find a solution.

OK, that’s all I need to know at the moment instead of wasting time with fiddeling around.

No hurry! I won’t need it within the next weeks. First I have to finish the 6 button prototype kbd before attacking the 10 button kbd.
Thanks for your efforts! Highly appreciate it.

regards:
-Serge-

Ok, tried the OnTimer and I get the following Error:

TIMER 00000000 1 Type Mismatch

Code is as follows:

[code]procedure OnTimer ;

var
sl: TStringList;
Newoption: TPlayerControlOptions;

begin

sl := TStringList.Create;
Newoption := (Engine.GetCartWallControl.GetPlayerControl(0).GetOptions);

  Case NewOption Of	
     poAutoLoad:             ;
     poAutoLoadOnDemand:     ;
     poAutoLoadSingle:       ;
     poAutoLoadSpecial:      ;
     poAutoUnloadSTOP:       ;
     poAutoUnloadEOF:        ;
     poAutoStopOnEOF:        ;
     poAutoReleasePause:     ;
     poAutoPFLOff:           ;
     poAutoStopPFL:          ;
     poAutoFadeOut:          ;
     poUseInAutomation:      ;
     poHistoryOnClose:       ;
     poHistoryOnCloseLoaded: ;
     poLogging:              ;

// poDatabaseLogging: ;
// poShoutcastLogging: ;
poIndependentPFL: ;
poPFLOutputPlayback: ;
poIndependentPFLEndMon: ;
poLoopAudio: sl.Add(‘1’);
poHookMode: ;
else sl.Add(‘0’);
end;

sl.SaveToFile(‘C:\LPT_Out\temp.txt’);
sl.Free;

end;

begin
end.[/code]

I also tried it with TPlayerState and there it just worked fine.

regards:
-Serge-

You cannot use “case” here, because TPlayerControlOptions is a set of values (more than one value can be set).

I also noticed that there is a problem with the GetOptions function, it will return an empty result, obviously due to missing functionality in the Pascal Script engine. I am looking at this and will provide an update.

Damned!

Of course it is a set… ::slight_smile:
Below code should now do it once GetOptions is fixed:

[code]procedure OnTimer;

var
sl: TStringList;

begin

sl := TStringList.Create;

if (poLoopAudio in Engine.GetCartWallControl.GetPlayerControl(0).GetOptions) then

  sl.Add('1')

else

  sl.Add('0');

sl.SaveToFile(‘C:\LPT_Out\temp.txt’);
sl.Free;

end;

begin
end.[/code]

Yes, that looks very much like the script I wrote for testing one hour ago :slight_smile:

You should wrap all stringlist-related code into try…finally so the stringlist is destroyed (and memory released) even if something goes wrong while saving:

sl := TStringList.Create;
try
  (fill and save stringlist)
finally
  sl.Free;
end;

Ok, please check out Build 643 which I just uploaded. I had to make some fundamental changes to the code (change the calling conventions of dozens of methods), but I think everything should work alright, including the GetOptions call.

By the way, I would declare a global variable to cache the status of the option so you don’t need to rewrite the file so often. What repeat interval are you going to use? And don’t forget that you need to enable the timer in OnStartup:

[begin]
procedure OnStartup;
begin
EnableTimer(1000);
end;

(rest of code follows here)
[/end]

Ok, I’ll test it and report back.
Interval of 1000ms is by far OK.

By the way, I would declare a global variable to cache the status of the option so you don't need to rewrite the file so often.
Hmm, I don't know what you mean with this...

Like this (untested):

var
  lastString: string;

procedure OnTimer;
var
  s: string;
  sl: TStringList;
begin
  if poLoopAudio in Engine.GetCartWallControl.GetPlayerControl(0).GetOptions then
    s := '1'
  else
    s := '0';

  if s <> lastString then begin
    sl := TStringList.Create;
    try
      sl.add(s);
      sl.SaveToFile('C:\LPT_Out\temp.txt');
    finally
      sl.Free;
    end;
    lastString := s;
  end;
end;

procedure OnStartup;
begin
  lastString := '';
  EnableTimer(1000);
end;

begin
end.

The last value written to the output file is cached in the global variable “lastString”. The file is only rewritten when the option value (and thus the output string) changes.

But if you’re only polling each 1000ms, and your computer is not as old as Cad’s ;), then you will get along well without this.

OK I understand now. Also why CAD sometimes has some trouble ;D

I quickly tested the readout and everything perfoms like expected.
I’ll just wrap it into a for next loop for reading out the 4 carts.

Thanks Torben!

Humph! There’s nothing wrong with my 1GHz CPU, 1GB RAM PC with onboard graphics!

It cost me £30 (maye €35–€40) several years ago. It was (ahem) “reclaimed” by the furniture shop it came from (yes, really a furniture shop) when its previous owner failed to make the credit payments, and it sat in their back store for another year before I was able to buy it cheap to ‘take it off their hands.’ ;D

Anyway, how else do you propose to find out the ‘minimum spec.’ PC for mAirList? :smiley:

BFN
CAD

Actually, Cad’s somewhat dated playout PC helped me to find some very inefficient GUI drawing code recently. Not so bad.

</kidding_off>

Here’s the final code for the cart Loopbutton readout:

[code]var
lastString: Array[0…3] of string;

procedure OnTimer;

var
s: string;
sl: TStringList;
i: integer;

begin
for i := 0 to Engine.GetCartWallControl.GetPlayerCount - 1 do begin
if poLoopAudio in Engine.GetCartWallControl.GetPlayerControl(i).GetOptions then
s := ‘1’
else
s := ‘0’;

 if s <> lastString[i] then begin
   sl := TStringList.Create;
   try
     sl.add(s);
     sl.SaveToFile('C:\LPT_Out\LP_' + INTTOSTR(i) + '.txt');
   finally
     sl.Free;
   end;
   lastString[i] := s;
 end;

end;
end;
[/code]

Had to look on how to declare the arrays. Sorry, but this script language is very powerful but new to me. ;D
Works perfectly! Now let me just add the exception catch for the other scripts in use.

But if someone has a link to a syntax manual of the scripting language, it would be highly appreciated.

Torben, many thanks again for working this out!
Hmm, we’re almost at the end of the year… I wonder if you ever tried a good champagne (cremant) from the Luxembourguese Moselle!?
If not, I’ll dispatch a couple for you. Our radiostation does this evey year for our outstanding supporters. :wink:

regards:
-Serge-

Dear Serge,

The scripting language is PascalScript, so any Delhi site will show you the basic syntax. Just remember that not every statement in Delphi is available in PascalScript. Torben has to do a lot of coding work to ‘enable’ each statement in mAirListScript; so mAirListScript is, if you like, a subset of Delphi. For example, you can’t display a MessageBox, which is why most mAirList scripts write error messages etc. to the System Log instead of using MessageBoxes.

The ‘mAirList-specific’ parts are contained in the mairlistscript.chm Windows help file. Things like PlayerControl and so on. The best way to learn how these work is to look at some existing mAirList scripts alongside the Help file. If you don’t have a copy, I’m pretty sure it’s downloadable from the 3.0 download page, either separately or in the current …setup.zip file.

Unfortunately, PascalScript itself seems to have no documentation whatsoever (believe me, I’ve looked HARD for it). A good Delphi site which I often use myself is http://delphibasics.co.uk/.

PS: If you’d like my house address, send me a PM: I promise to put the champagne to good use (conversion to Pan-Galactic Gargle Blasters: recipe on request!).

[THINKS: Oh well, it was worth a try!!!] :smiley:

BFN
CAD

CAD’s PS comment was exactly what I expected… ;D

OK, for reference here’s the final script. I fiddled around to get into the situation where mAiList’s atempt to write failed. So the try-catch script worked fine, however with the global variable being always updated in the former code, the output state did not reflect the player state after unsucessful write. I now changed it so that the global compare variable only gets updated on a sucessful write.
If now a write fails, the output status gets updated one scan later (if successful)

regards:
-Serge-

[code]var
lastString: Array[0…3] of string;

procedure OnTimer;

var
s: string;
sl: TStringList;
i: integer;

begin
for i := 0 to Engine.GetCartWallControl.GetPlayerCount - 1 do begin
if poLoopAudio in Engine.GetCartWallControl.GetPlayerControl(i).GetOptions then
s := ‘1’
else
s := ‘0’;

  if s <> lastString[i] then begin
     sl := TStringList.Create;
     try
        sl.add(s);
        sl.SaveToFile('C:\LPT_Out\LP_' + INTTOSTR(i) + '.txt');
        lastString[i] := s;
     finally
        sl.Free;
     end;
  end;

end;
end;[/code]

Perfect solution.

Oh, and I don’t think I’ve ever tried any Crémant from Luxembourg, but it sounds very promising :slight_smile:

OK, so be prepared to receive a parcel within the next 3 weeks. (CAD, stop reading here ;D )

The crémant is from our private wine grower “Cep d’Or”
Sorry but the webpage is in french.
www.cepdor.lu (they are also supporter of R.O.M, BTW)
If you want my opinion, it’s one of the best!
So let me fetch the special bottle shipping parcels from our post office first (I don’t have any left for the moment)
…and then we’ll put them into mail asap.

regards:
-Serge-

:’(

Oh well, it was worth a try! :smiley:

BFN
CAD