axiom-developer
[Top][All Lists]
Advanced

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

RE: clarification Re: [Axiom-developer] retrieving axiom commands


From: Bill Page
Subject: RE: clarification Re: [Axiom-developer] retrieving axiom commands
Date: Tue, 23 Jan 2007 11:33:47 -0500

On January 22, 2007 5:39 PM Arthur Ralfs wrote:
> 
> I want to retrieve the command from within spad code,
> not from the command line
> 
> Thanks
> 
> Arthur Ralfs wrote:
> > Is it possible to retrieve axiom commands?
> > i.e. if I type in integrate(x**2,x) can I then get
> > that command back rather than the output from
> > the command?
> >

Oh ok, that's different. I don't think there is an standard
interface to do this but you can resort to accessing the
underlying Boot/Lisp variable |$currentLine|. See documentation
about the Axiom interpreter "top level loop" here:

http://wiki.axiom-developer.org/axiom--test--1/src/interp/IntTopBoot
http://wiki.axiom-developer.org/axiom--test--1/src/interp/IntintLisp

For example:

(1) -> )lisp (print |$currentLine|)

")lisp (print |$currentLine|)"
Value = ")lisp (print |$currentLine|)"

(2) -> _$currentLine$Lisp

   (2)  _$currentLine$Lisp
                                         Type: Sexpression

In SPAD you can write something like this:

--- File: CommandLine.spad ---
)abbrev package CL CommandLine
CommandLine(): Exports == Implementation where
  Exports ==> with
    current: () -> String
  Implementation ==> add
    current() ==
      -- if $currentLine is a list, command is last entry
      if list?(_$currentLine$Lisp)$SExpression then
        string last(_$currentLine$Lisp)$Lisp
      else
        string _$currentLine$Lisp

--- end ---

(3) -> )co CommandLine.spad
   Compiling AXIOM source code from file
   ...

(3) -> current()$CommandLine
   Loading
      /Documents and Settings/Administrator.ASUS/My Documents/CL.NRLIB/code
      for package CommandLine

   (3)  "current()$CommandLine"
                                         Type: String


Does that help?

Regards,
Bill Page.






reply via email to

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