Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: Matt_H on June 10, 2009, 09:33:11 PM

Title: Question from an ARexx newbie
Post by: Matt_H on June 10, 2009, 09:33:11 PM
I'm trying to use ARexx to create a remote control for Amplifier. Amplifier has the command VOLUME which returns the current volume when passed no arguments and sets the new volume when passed a number.

As my ARexx manuals aren't with me right now, can anyone walk me through converting the logical expression VOLUME=VOLUME+1 into real ARexx syntax?

Thanks
Title: Re: Question from an ARexx newbie
Post by: Karlos on June 10, 2009, 09:39:37 PM
Wow, I haven't written any ARexx code in ages :) I actually used to know it pretty well.

I'm assuming you can't do what you've written directly so I am going to assume you need to capture the value of VOLUME command to a variable, increment that and then use it as an argument to a second call to the VOLUME command.
Title: Re: Question from an ARexx newbie
Post by: Daedalus on June 10, 2009, 10:39:09 PM
I'm a little rusty myself but I did write just such a script years ago for my InfraRexx setup... How about something like this:

Code: [Select]
ADDRESS AMPLIFIER.1
'VOLUME'
MyVol = RESULT
MyVol = MyVol + 10
IF MyVol > 64 THEN MyVol = 64

'VOLUME 'MyVol

Think that should work to up the volume, and check to make sure you don't go above the maximum value of 64. Bear in mind that different players have different volume scales (IIRC AmigaAmp goes from 0 to 26), and that I remember steps of 1 were far too small to be useful or even noticeable, so I think I used 5 or 10. Experiment there...
Title: Re: Question from an ARexx newbie
Post by: Matt_H on June 10, 2009, 11:40:23 PM
Thanks for that, but where does the returned value of VOLUME go? Does it actually go to RESULT? If that's the case, I'm having some data type issues, since the subsequent lines of the example treat it as the letters R E S U L T rather than a number.
Title: Re: Question from an ARexx newbie
Post by: Daedalus on June 10, 2009, 11:50:43 PM
Quote from: Matt_H;510480
Thanks for that, but where does the returned value of VOLUME go? Does it actually go to RESULT? If that's the case, I'm having some data type issues, since the subsequent lines of the example treat it as the letters R E S U L T rather than a number.


Oh, maybe it doesn't then... Usually in ARexx you issue a command to the application (in this case 'VOLUME' without an argument), and the app puts the result in a special variable called RESULT. If a variable is empty/unused in ARexx however, it defaults to the string you're seeing. I guess Amplifier works differently to how I remember...

Crap! Don't forget to put OPTIONS RESULTS at the top of your script - like I did ;) Without it ARexx is unable to accept RESULTS values...
Title: Re: Question from an ARexx newbie
Post by: Matt_H on June 10, 2009, 11:56:14 PM
Quote from: Daedalus;510484
Crap! Don't forget to put OPTIONS RESULTS at the top of your script - like I did ;) Without it ARexx is unable to accept RESULTS values...


Bingo! Thanks.
Title: Re: Question from an ARexx newbie
Post by: Tension on June 11, 2009, 12:02:21 AM
I always wanted to learn AREXX.  Suppose there`s not much point now... :-(

vv SIGN IT vv
Title: Re: Question from an ARexx newbie
Post by: pVC on June 11, 2009, 06:38:02 AM
Here's a little clip of my "multimedia" arexx-script which I use with MMKeyboard (or any other similar commodity), maybe it's useful:


Code: [Select]


SIGNAL ON SYNTAX

OPTIONS RESULTS
PARSE ARG kasku jauhe

IF SHOW( "P", "AMINETRADIO.1"  ) THEN SIGNAL ANR
IF SHOW( "P", "AMPLIFIER.1"  ) THEN SIGNAL AMPLIFIER
IF SHOW( "P", "SONGPLAYER.1" ) THEN SIGNAL SONGPLAYER
IF SHOW( "P", "AMIGAAMP"     ) THEN SIGNAL AMIGAAMP

IF kasku = "stop" THEN ADDRESS COMMAND "Utils:Audio/amplifier/AMPlifier"
ELSE ADDRESS COMMAND "Utils:Audio/amplifier/AMPlifier Store:MP3/"

EXIT

AMPLIFIER:
    ADDRESS "AMPLIFIER.1"
    IF kasku = "next" THEN DO
        PLAYNEXT
    END
    IF kasku = "prev" THEN DO
        PLAYPREV
    END
    IF kasku = "stop" THEN DO
        STOP
    END
    IF kasku = "play" THEN DO
        PLAYPAUSE
    END
    IF kasku = "volup" THEN DO
        VOLUME
        currvol = result + 4
        IF currvol > 64 THEN currvol=64
        VOLUME currvol
    END
    IF kasku = "voldown" THEN DO
        VOLUME
        currvol = result - 4
        IF currvol < 0 THEN currvol=0
        VOLUME currvol
    END
    IF kasku = &quot;mute&quot; THEN DO
        VOLUME 0
    END
    EXIT

Title: Re: Question from an ARexx newbie
Post by: bigdan on June 19, 2009, 09:17:56 PM
Matt_H : you could also drop an eye on "telecommande" arexx script (made by my friend Vincent aka Wickedvinz / Purelamers) ...

See

http://wickedvinz.free.fr/index_rns.html
http://wickedvinz.free.fr/files/Telecommande_v0.8.readme

Good beginning in ARexx world ;-P