內容

名稱

Amiga::ARexx - ARexx 支援的 Perl 擴充套件

摘要

這是一個 perl 類別/模組,可讓您在 perlscript 中使用 ARexx。建立函式主機或在其他主機中執行指令碼。API 鬆散地建構於 AmigaOS4.1 提供的 python arexx 模組上。

語法

# Create a new host

use Amiga::ARexx;
my $host = Amiga::ARexx->new('HostName' => "PERLREXX" );

# Wait for and process rexxcommands

my $alive = 1;

while ($alive)
{
    $host->wait();
    my $msg = $host->getmsg();
    while($msg)
    {
        my $rc = 0;
        my $rc2 = 0;
        my $result = "";

        print $msg->message . "\n";
        given($msg->message)
        {
            when ("QUIT")
            {
                $alive = 0;
                $result = "quitting!";
            }
            default {
                $rc = 10;
                $rc2 = 22;
            }
        }
        $msg->reply($rc,$rc2,$result);

        $msg = $host->getmsg();
    }

}

# Send a command to a host

my $port = "SOMEHOST";
my $command = "SOMECOMMAND";
my ($rc,$rc2,$result) = Amiga::ARexx->DoRexx($port,$command);

說明

arexx.class 的介面完全封裝在 perl 類別中,不需要直接存取低階方法,而且它們預設不會匯出。

Amiga::ARexx 方法

new

my $host = Amiga::ARexx->new( HostName => "PERLREXX");

為您的腳本/程式建立 ARexx 主機。

HostName

主機命令埠的 HostName。這是強制性的,如果未提供,程式將會失敗。

wait

$host->wait('TimeOut' => $timeoutinusecs );

等待訊息到達埠口。

TimeOut

微秒的選擇性逾時。

getmsg

$msg = $host->getmsg();

從主機埠擷取 ARexx 訊息。傳回 Amiga::ARexx::Msg 類別的物件。

signal

$signal = $host->signal()

擷取主機埠的訊號遮罩,供 Amiga::Exec Wait() 使用。

DoRexx

($rc,$rc2,$result) = DoRexx("desthost","commandstring");

將「commandstring」傳送至主機「desthost」執行。Commandstring 可能為特定命令或腳本名稱。

Amiga::ARexx::Msg 方法

message

$m = $msg->message();

以字串形式擷取訊息「command」;

reply

$msg->reply($rc,$rc2,$result)

回覆訊息,傳回任何命令的結果。將 $rc 設定為 0 表示成功,並在適當的情況下將 $result 設定為結果字串。

在發生錯誤時將 $rc 設定為非零,並在適當的情況下將 $rc2 設定為其他錯誤碼。

setvar

$msg->setvar($varname,$value)

設定傳送此訊息的語言環境中的變數。

getvar

$value = $msg->getvar($varname)

取得傳送此訊息的語言環境中的變數值。

EXPORT

預設為無。

可匯出的常數

AUTHOR

Andy Broad <andy@broad.ology.org.uk>

COPYRIGHT AND LICENSE

版權所有 (C) 2013 Andy Broad。