Macro prompt array

Macro prompt array

1
NewbieNewbie
1

    Aug 23, 2005#1

    Hey all,
    I'm trying to create a macro that asks a user for how many lines of text to insert. The end result will be this is the user typed in "3":

    <ul>
    <li></li>
    <li></li>
    <li></li>
    </ul>

    (you can see where I'm going with this) The user is prompted for how many list items he wants and the above is inserted if he responds with "3".

    Thanks for any help!
    :?

    2
    NewbieNewbie
    2

      Aug 23, 2005#2

      Benway wrote:Hey all,
      I'm trying to create a macro that asks a user for how many lines of text to insert. The end result will be this is the user typed in "3":

      <ul>
      <li></li>
      <li></li>
      <li></li>
      </ul>

      (you can see where I'm going with this) The user is prompted for how many list items he wants and the above is inserted if he responds with "3".
      :?
      I think you're going to have to approach this from a different angle. Have them enter the list elements, then have your macro create the HTML around it.

      Bob

      206
      MasterMaster
      206

        Aug 24, 2005#3

        I don't know what range of lines you might want - here's a very klutzy approach that covers from 1 to 4 lines. You can easily add more sections to increase the range. Above 9 will require more effort.

        Maybe you or somebody else can tuck a loop in there to shorten up the code.

        It's too bad that UE macros don't handle simple math.



        InsertMode
        ColumnModeOff
        HexOff
        UnixReOn
        Key HOME
        "
        "
        Key UP ARROW
        GetString "Number of Elements"
        Key HOME
        IfCharIs "1"
        "
        <ul>
        <li></li>
        </ul>
        "
        EndIf
        IfCharIs "2"
        "
        <ul>
        <li></li>
        <li></li>
        </ul>
        "
        EndIf
        IfCharIs "3"
        "
        <ul>
        <li></li>
        <li></li>
        <li></li>
        </ul>
        "
        EndIf
        IfCharIs "4"
        "
        <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        </ul>
        "
        EndIf
        Delete
        Delete
        Find Up "<ul>"
        Key UP ARROW
        Delete
        Software For Metalworking
        http://closetolerancesoftware.com

        261
        Basic UserBasic User
        261

          Aug 24, 2005#4

          Here is one way to do it. It only handles up to 10 inserted lines at a time, but you could add more if you needed it.

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOn
          NewFile
          Clipboard 9
          GetValue "How many lines do you want? "
          SelectWord 
          Cut 
          Top
          "1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          "
          Top
          Find Select "^c"
          IfNotFound
          CloseFile NoSave
          Clipboard 0
          ExitMacro
          EndIf
          StartSelect
          Key RIGHT ARROW
          Find RegExp "^.*$"
          Replace All SelectText "<li></li>"
          EndSelect
          Key LEFT ARROW
          Key END
          Key RIGHT ARROW
          SelectToTop
          Copy 
          CloseFile NoSave
          Paste 
          Clipboard 0
          
          Basically it opens an empty buffer, prompts for the number of lines, then inserts line numbers 1-10 (you could make more) and finds the entered number using the ^c (find text in clipboard). This will position the cursor on the line number entered. Once you have the proper number of lines selected, it does a simple replace on each of the selected lines with the desired text, copies it, closes the temporary buffer, and pastes it into the original text. Clipboard 9 is used so as to not clobber anything previously in the clipboard.

          If you enter more than the number of lines in the temporary buffer, it does nothing. (You could give something else, but I thought this might be the most obvious result that something was wrong.

          Hope this helps!

          Dave
          ASTTMan
          I'm not a Texan, I just live here.