Re: Suggested change to STk

From: Kumar Balachandran <kumar_at_rtp.ericsson.se>
Date: Thu, 4 Sep 1997 10:02:44 -0400

I use STk to give me widgets when performing a simulation composed of
several independent programs. The programs communicate with each other
using pipes, and one particular program passes input data through
while processing it and passing information to an stk session that I
create using

    // initiate stk session
    sprintf(cname,"stk -prompt-stderr %s %s 2>/dev/null",
            (char *)hname,
            (const char *) textlabel);

    fstk = popen(cname,"w");
                ...
                ...
                ...
    stkdes = fileno(fstk);

    int i = 0;
    while (stkprogram[i] != NULL){
        // send scheme code to stk
        fprintf(fstk,"%s\n",stkprogram[i++]);
    }
    fflush(fstk);
                ...
                ...
                ...
    // inp is derived from fstream and fstreambase and handles vectors
    while (*inp >> insig){
        // calculate frmcnt sltcnt and pctg
                ...
                ...
        fprintf(fstk,"( %d %d %3.0f ) \n", frmcnt, sltcnt,pctg);
        fflush(fstk);
                ...
                ...
        *out << insig;
    }

The problem I had was that the results of the scheme execution were
appearing in the port out (#undefined, (), etc.) The hack I sent fixes
this and pipes all top level output to stderr, since it is not a true
interactive session. From what you say, there seems to be a cleaner
way of doing this that I am not aware of.




>>>>> "Shiro" == Shiro Kawai <shiro_at_sqla.com> writes:

>> Date: Wed, 3 Sep 1997 15:52:45 -0400 From: Kumar Balachandran
>> <kumar_at_rtp.ericsson.se>
>>
>> However, if you have a situation where a program c-program.c
>> uses popen to instantiate an intreractive stk session, STk
>> should only pass the output of a (write <variable>) or a
>> (display <variable>) to *stdout*.

    Shiro> Hmm... I cannot see any reason to do that. To use popen,
    Shiro> I assume you expect that stk repl behaves just like usual
    Shiro> interactive session... Otherwise you can just link stk
    Shiro> module to your program (and use STk_eval_string() or
    Shiro> something). Am I missing your point?

    Shiro> -- Shiro KAWAI
    Shiro> Square USA Inc. 4640 Admiralty Way, Suite 1200, Marina
    Shiro> del Rey CA 90292 Phone 310 302 9500 Fax 310 302 9550
    Shiro> E-mail shiro_at_sqla.com
    Shiro> #"The most important things are the hardest things to say"
    Shiro> #--- Stephen King
Received on Thu Sep 04 1997 - 16:00:51 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST