Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Using $PreRead with Notebook frontend

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

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 1.1.1.1 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 1.1.1.1 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];
Close[st];
    res]

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

TokenListToString[{}] := ""

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


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

/Ö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