Welcome, Guest. Please login or register.

Author Topic: Question from an ARexx newbie  (Read 2362 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Matt_HTopic starter

Question from an ARexx newbie
« 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
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Question from an ARexx newbie
« Reply #1 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.
int p; // A
 

Offline Daedalus

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 893
    • Show only replies by Daedalus
    • http://www.robthenerd.com
Re: Question from an ARexx newbie
« Reply #2 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...
Engineers do it with precision
--
http://www.robthenerd.com
 

Offline Matt_HTopic starter

Re: Question from an ARexx newbie
« Reply #3 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.
 

Offline Daedalus

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 893
    • Show only replies by Daedalus
    • http://www.robthenerd.com
Re: Question from an ARexx newbie
« Reply #4 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...
Engineers do it with precision
--
http://www.robthenerd.com
 

Offline Matt_HTopic starter

Re: Question from an ARexx newbie
« Reply #5 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.
 

Offline Tension

Re: Question from an ARexx newbie
« Reply #6 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

Offline pVC

Re: Question from an ARexx newbie
« Reply #7 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

Daily MorphOS user and Amiga active.
 

Offline bigdan

  • Full Member
  • ***
  • Join Date: Aug 2004
  • Posts: 149
    • Show only replies by bigdan
    • http://www.amigaimpact.org/
Re: Question from an ARexx newbie
« Reply #8 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
www.amigaimpact.org the fresh french news for Amiga and Pegasos !