When creating an ARexx port it is needed to evaluate the next free port number (like "MY_COOL_PORT.1"). This is of course possible to do like this:
Code: Select all
Function p_ARexxPortExists(portName$)
Local checkPort = RunRexxScript("if show(ports,'" .. portName$ .. "') then return 'yes'", True)
Return(checkPort = "yes")
EndFunction
m_arexxPortName$ = "MY_COOL_PORT"
Local count = 1
Local name$ = m_arexxPortName$ .. "." .. count
While p_ARexxPortExists(name$)
count = count + 1
name$ = m_arexxPortName$ .. "." .. count
Wend
CreateRexxPort(name$)
m_arexxPortName$ = name$
Code: Select all
m_arexxPortName$ = CreateRexxPort("MY_COOL_PORT", True)
What do you think?
And while you're at it, why not integrate a default function ARexxPortExists(portName$) as well, could always come in quite handy, I think.
Cheers,
Michael