Translating lisp -- Please help!!!

Discussion in 'AutoCAD' started by André Dantas Rocha, May 15, 2004.

  1. Hi,

    I neeed to translate about 150 autolisp routines. Basically, I have to
    prefix the commands with "._" and the command options with "_", as shown
    below:

    (command "pline" "0,0" "w" "3" "" "10,10" "")

    (command "._pline" "0,0" "_w" "3" "" "10,10" "")

    My (big) problem is that the command could have parentesis inside like that:

    (command "pline" (calculate_start_point) ...)

    and I have to distigue between options and inputs (like "w" and "3").

    Actually I'm trying to write a parser, but I think it is very complex...

    Is there a way to do this automatically?

    Please help me!!!!

    Thanks,

    Andre
     
    André Dantas Rocha, May 15, 2004
    #1
  2. André Dantas Rocha

    TCEBob Guest

    If they are not very long routines, consider loading all into the same
    editor (I use TextPad) as a single file with separators at each start so
    they can easily be broken out later.

    Most editors support "regular expressions" for complex search and
    replace operations. Unless you happen to be experienced at REs (and I am
    not) stay away from them; you can do unimaginable damage with a single
    keystroke.

    I would start at the top of the combined file and read until I found a
    command that needed to be changed. Then I would Find and Replace that
    command throughout the file. Editors make that part easy. I would
    continue doing that until the entire file was processed. I know that
    sounds like a lot of drudgery but you will find that the most common
    commands will be taken care of quickly and you will find fewer and fewer
    as you progress.

    Perhaps there is a program to do what you need. However, writing a
    program for yourself will prove more time-consuming than the suggested
    procedure.

    rs
     
    TCEBob, May 15, 2004
    #2
  3. André Dantas Rocha

    ECCAD Guest

    Andre,
    For small investment. Search&Replace see:
    www.funduc.com
    (I am not affiliated, just use the program - very good)
    I changed > 1200 routines using this tool in less than an hour.

    Bob
     
    ECCAD, May 16, 2004
    #3
  4. André Dantas Rocha

    anguilla Guest

    why not just changing in text editor each occurence of the string (command " with the string (command "._ ? it should do what you need for all commands.
    For command options I think it should only be executed as many times as many characters the ABC has, since options begin always with such characters not numbers. By changing each "a to "_a up to each "z to "_z should solve the problem.
    This all could also be written into a very simple ms-basic routine or even acad-batch file to ease the whole stuff.
     
    anguilla, May 20, 2004
    #4
  5. André Dantas Rocha

    TCEBob Guest

    If that's all he needs, it's almost great. You have to account for commands that
    already have ._ so they don't double. Two strikes: 1) Replace [(command "._]
    with [Command "]. 2) Like you said. Unless there are some with ". and others
    with "_ etc. Then either go through 2 more times or Regular Expressions.

    rs

    with the string (command "._ ? it should do what you need for all commands.
    characters the ABC has, since options begin always with such characters not
    numbers. By changing each "a to "_a up to each "z to "_z should solve the
    problem.
    acad-batch file to ease the whole stuff.
     
    TCEBob, May 20, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.