/* Nodelist look-up for Spot        */
/* by Johan Billing 2:203/602.32    */

/* Tiny manual: If you want to, you can write REQ as a parameter   */
/* for the script in the ARexx window. The script will then open a */
/* string requester where you can enter a node to look up.         */

nodelist = "NODELIST:"

IF ~SHOW(Libraries,'traplist.library') THEN
    IF ~ADDLIB("traplist.library",0,-30,0) THEN EXIT

cr='0d'x

options results
address 'SPOT'

parse arg req

if upper(req)=="REQ" then do
 node=""
 call asknode
 res = FindNode(node,"All",nodelist)
end
else do
 getfromaddress
 node=result
 point=0
 parse var node zone":"net"/"nod"."point

 res = FindNode(node,"All",nodelist)

 if left(res,1)=="0" & point~=0 then do
  point=0
  node=zone":"net"/"nod"."point
  say node
  res = FindNode(node,"All",nodelist)
 end
end

do forever
 parse var res error" "nod","sysop","name","phone","city","password","baud","cost","region","hub","flags
 parse var node zone":"net"/"nod"."point

 if left(res,1)=="0" then do
  string="Node "node" not found"
  title="IntuiNode.rexx Error"
 end
 else do
  string=" Name: " || left(name,40) || cr || "Sysop: " || left(sysop,22) || "City: " || city || cr || "Phone: " || left(phone,22) || "Baud: " || baud || cr || "Flags: " || flags
  title="Node "node
 end

 if point==0 then do
  gads="_New node|_Quit"
 end
 else do
  gads="_New node|_Boss|_Quit"
 end

 'requestresponse TITLE "' || title || '" PROMPT "' || string || '" GADGETS "' || gads || '"'

 if rc==0 then do
  exit
 end

 else if rc==1 then do
  call asknode
  res = FindNode(node,"All",nodelist)
 end

 else if rc==2 then do
  point=0
  node=zone":"net"/"nod"."point
  res=FindNode(node,"All",nodelist)
 end
end

asknode:
 'requeststring TITLE "Enter a node number" DEFAULT "'node'"'
 node=result

 if node=="" | rc==5 then do
  exit
 end

 return
