MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Using $PreRead with Notebook frontend

  • To: mathgroup at
  • Subject: [mg13593] Using $PreRead with Notebook frontend
  • From: "Orjan Gustavsson" <orjan at>
  • Date: Mon, 3 Aug 1998 03:53:53 -0400
  • Organization: Bahnhof Customer News Posting
  • Sender: owner-wri-mathgroup at

I'm trying to make a package to interpret and manipulate Cisco Access
Lists. I want to simplify input by assigning a function to $PreRead
that will replace all ip addresses in the form with
IPAddr[1,1,1,1]. My problem is that when I try this with the notebook
frontend the input string that is passed to $PreRead has already been
interpreted in part by the frontend, so is wrapped with RowBox
objects in a nontrivial way.

The following code works when used without notebook frontend. (I'm sorry
it is not the prettiest of codes, but I'm rather new at this :)

StringTokenize[s_String] :=
  Module[{st, res}, res = ReadList[st = StringToStream[s], Word];

TokenListToString[sl_List] :=
  StringJoin[Drop[Flatten[Transpose[{sl, Array[" "&,Length[sl]]}]], -1]]

TokenListToString[{}] := ""

$PreRead = (
        StringTokenize[#] /.
          a_String :>
            ToString[IPAddr[StringReplace[a, {"." -> ","}]]] /;
              StringMatchQ[a, "*.*.*.*"]])&

Anyone got any ideas of how to get this to work with the Notebook

/Örjan Gustavsson

  • Prev by Date: Mandelbrot
  • Next by Date: Re: problem with Needs[ ] command
  • Previous by thread: Re: Mandelbrot
  • Next by thread: Re: problem with Needs[ ] command