help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interactive mode


From: Paul Kienzle
Subject: Re: Interactive mode
Date: Tue, 18 Jun 2002 09:23:49 -0400

On Sun, Jun 09, 2002 at 08:01:34PM -0500, Ravikiran Rajagopal wrote:
> Hello,
>   I am writing a KDE GUI interface for Octave. It runs Octave as a separate 
> process, and manipulates the stdin and stdout handles. The output is usually 
> given a pretty face before being shown to the user, or is exported to a LaTeX 
> format, etc. I have a few questions about how the output is handled. 
>   I prefer to force the Octave process to run interactively so that the users 
> may get their customized prompts. However, when run interactively, paging is 
> enabled, and this messes up my GUI. Is there a hook available by which I can 
> override pagination defaults after the user's ~/.octaverc file is read? I 
> cannot send commands to Octave at that point without confusing the user.

I have a hack for starting octave with an initial command and continuing in
interactive mode which I recently posted on octave-sources.  It creates a new
octave init file which sources the user's octaverc then executes the extra
command.  Here is an improved version:

ioctave:

#! /bin/sh

# Start octave with an initial command.

# This program is public domain.

# Check if the user has a special OCTAVE_INITFILE, or use default .octaverc
[ -z "$OCTAVE_INITFILE" ] && OCTAVE_INITFILE=.octaverc

# Check if OCTAVE_INITFILE exists. If so, make sure that it is sourced as
# soon as we enter octave. Note that octave first processes ~/.octaverc
# then if it is different, ./.octaverc 
STARTUP=""
[ -r $HOME/$OCTAVE_INITFILE ] && STARTUP="source('$HOME/$OCTAVE_INITFILE');" 
[ -r ./$OCTAVE_INITFILE -a ! ./$OCTAVE_INITFILE -ef $HOME/$OCTAVE_INITFILE ] \
    && STARTUP="$STARTUP source('./$OCTAVE_INITFILE');"

# Construct a replacement OCTAVE_INITFILE script which will contain the
# initial command.
SCRIPT=`mktemp $HOME/octXXXXXX` || exit 1

# The 'trap' command removes our script on exit.
trap "rm -f $SCRIPT" 0

# Reset OCTAVE_INITFILE in octave to protect against recursive calls.
OCTAVE_INITFILE_ORIG=$OCTAVE_INITFILE  
export OCTAVE_INITFILE_ORIG

# Populate our script file
cat > $SCRIPT <<EOF 
   putenv("OCTAVE_INITFILE",getenv("OCTAVE_INITFILE_ORIG"));
   $STARTUP
   $*
EOF

# Start octave using our script
OCTAVE_INITFILE=`echo $SCRIPT | sed -e "s|$HOME/||"`
export OCTAVE_INITFILE 
octave --silent



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]