I have the following pair of files; master loads slave and activates it.
Without the break in the slave.icn file, it doesn't stop.  I cannot
understand why, when response() fails, slave does not stop unless I include
the "break".  The last thing written is:
"master response - normal termination" and then it "hangs".
Any insight would be most welcome; I'm stumped.



# master.icn
procedure main()
  local Cfunction, Cresponse, T
  T := table()
  @( Cfunction := create response() )
  @( Cresponse := load("slave",[Cfunction],&input,&output,&errout) )
  write( "master main - normal termination" )
end

procedure response()
  local Tout, Tin, s
  Tin := @&source
  every s := "hello" | "hello" | "invalid" | "stop" | "stop" do {
    Tout := table()
    Tout["command"] := s
    Tin := Tout@&source
    Tin["response"]=="OK" & every writes( !Tin["strings"] || " " )
    write( "response = " || Tin["response"] )
  }
  write("master response - normal termination")
  fail
end




# slave.icn
procedure main(argv)
  local C, T
  C := argv[1]
  type(C)=="co-expression" | {
    ("this program must be loaded with the load procedure, \n"||
      "not run from the command line")@&source
    fail
  }
  T := table()
  T["response"] := "OK"
  while (T := T@C) do {
    write("command = "||T["command"])
    case T["command"] of {
      "stop": break stop("slave makes his exit")
      "hello": {
        T["response"] := "OK"
        T["strings"] := ["hello","world"]
      }
      default: T["response"] := "FAIL"
    }
  }
end





-------------------------------------------------------
In remembrance
www.osdn.com/911/
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to