Copy each line and save as html file.

Copy each line and save as html file.

12
Basic UserBasic User
12

    Sep 21, 2005#1

    Hi,

    Here are samples of the text:

    Code: Select all

    105:1 Lorem ipsum dolor sit amet.
    105:2 Consectetuer adipiscing elit.
    105:3 Maecenas venenatis semper lorem.
    105:4 Mauris dapibus.
    105:5 Phasellus tempor est vitae nulla.
    106:0 Aliquam tempor augue eu purus.
    I would like to copy each line and save to a new HTM file. I wanted to create a popup HTML file based on the saved file.

    Example:

    Copy 105:1 Lorem ipsum dolor sit amet. and save as s105a1.htm

    next

    Copy 105:2 Consectetuer adipiscing elit. and save as s105a2.htm

    The layout of the HTM file are like this:

    Code: Select all

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Pop Up</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    <SCRIPT TYPE="text/javascript">
    <!--
    window.focus();
    //-->
    </SCRIPT>
    </head>
    <body class="c">
    <p>[b]Lorem ipsum dolor sit amet. (105:1)[/b]</p>
    <hr size="1" noshade>
    <p align="center"><a href="javascript:window.close()">X close X </a>
    </p>
    </body>
    </html>
    Note that the arrangement of the text have been changed. Is it possible to do that too?

    Kindly advise on how can I do it with UE. Thanks.

    6,686585
    Grand MasterGrand Master
    6,686585

      Sep 22, 2005#2

      That was no problem for me:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Clipboard 9
      Bottom
      IfColNum 1
      Else
      "
      "
      EndIf
      Top
      Loop
      IfEof
      ExitLoop
      EndIf
      SelectLine
      StartSelect
      Copy
      EndSelect
      Key HOME
      NewFile
      Paste
      Top
      StartSelect
      Find RegExp "%[0-9]+:[0-9]+"
      Copy
      EndSelect
      Top
      Find RegExp "%^([0-9]+:[0-9]+^) +^(*^)$"
      Replace All "^2 (^1)"
      "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//ENhttp://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title> "
      Paste
      " </title>
      <link href="style.css" rel="stylesheet" type="text/css">
      <SCRIPT TYPE="text/javascript">
      <!--
      window.focus();
      //-->
      </SCRIPT>
      </head>
      <body class="c">
      <p>"
      Key END
      "</p>
      <hr size="1" noshade>
      <p align="center"><a href="javascript:window.close()">X close X </a>
      </p>
      </body>
      </html>"
      Top
      Find RegExp "([0-9]+:[0-9]+)"
      StartSelect
      Copy
      EndSelect
      Top
      Paste
      Key BACKSPACE
      ".htm"
      Key HOME
      Key DEL
      "s"
      StartSelect
      Find ":"
      "a"
      EndSelect
      Key HOME
      Find RegExp "%*.htm"
      StartSelect
      Cut
      SaveAs "^c"
      CloseFile
      EndLoop
      ClearClipboard
      Clipboard 0
      UnixReOn

      Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style - see Advanced - Configuration - Find - Unix style Regular Expressions. UnixReOn/UnixReOff modifies this setting.

      The macro does not modify the source file, except the last line does not end with a line termination (CR+LF) which is necessary to detect end of file.

      From a HTML writers view, you should give each file it's own <title></title>. And if all texts are so short like your example, I would suggest to use the title attribute in the appropriate source file(s) instead of creating annoying pop-up windows. The title attribute can be used for every HTML element and all browsers shows the text of the title attribute as tooltip, when the mouse is positioned over the element.

      Edit: New macro code for inserting the number as title for the html file as requested.
      Best regards from an UC/UE/UES for Windows user from Austria

      12
      Basic UserBasic User
      12

        Sep 22, 2005#3

        Hi Mofi,

        Thank you so much.

          Sep 23, 2005#4

          Hi!

          Let say, now the text looks like this,

          Code: Select all

          105:1 Lorem ipsum dolor sit amet.
          105:2 Consectetuer adipiscing elit.
          105:3 Maecenas venenatis semper lorem.
          201:4 Mauris dapibus.
          201:5 Phasellus tempor est vitae nulla.
          301:0 Aliquam tempor augue eu purus.
          301:3 Maecenas venenatis semper lorem.
          301:4 Mauris dapibus.
          302:5 Phasellus tempor est vitae nulla.
          I would like to copy all similar numbers to one htm file.
          Example;

          All lines started with 105:... will be save as s105.htm
          All lines started with 201:... will be save as s201.htm
          And so on...

          The HTM file layout should look like this;
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          <title>105</title>
          <link href="style.css" rel="stylesheet" type="text/css">
          </head>
          <body class="c">
          <p>Lorem ipsum dolor sit amet. (105:1)</p>
          <p>Consectetuer adipiscing elit. (105:2)</p>
          <p>Maecenas venenatis semper lorem. (105:3)</p>

          </body>
          </html>

          Thanks.

          6,686585
          Grand MasterGrand Master
          6,686585

            Sep 23, 2005#5

            Can also be done with macros. But this time a nested loop is necessary, which is not possible in UltraEdit's macro language. So the inner loop must be saved in an extra macro.

            We need two macros. For both macros, the macro property "Continue if a Find with Replace not found" must be set.

            The macro with the inner loop is named SubMacro.

            Macro SubMacro

            Loop
            Find RegExp "%^c:*^p"
            IfFound
            Clipboard 9
            CutAppend
            Clipboard 8
            Else
            ExitLoop
            EndIf
            EndLoop

            This macro collects the lines with identical starting number. This macro uses UltraEdit style regular expression (activated in the main macro) and this find cannot be done with a Unix style regular expression, because ^c cannot be used in an Unix style regular expression.


            Macro MainMacro

            InsertMode
            ColumnModeOff
            HexOff
            UnixReOff
            Bottom
            IfColNum 1
            Else
            "
            "
            EndIf
            Loop
            Top
            Clipboard 9
            ClearClipboard
            Clipboard 8
            Find RegExp "%[0-9]+"
            IfNotFound
            ExitLoop
            EndIf
            StartSelect
            Copy
            EndSelect
            Top
            PlayMacro 1 "SubMacro"
            NewFile
            Clipboard 9
            Paste
            Top
            Find RegExp "%^([0-9]+:[0-9]+^) +^(*^)$"
            Replace All "<p>^2 (^1)</p>"
            Top
            "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//ENhttp://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>"
            Clipboard 8
            Paste
            "</title>
            <link href="style.css" rel="stylesheet" type="text/css">
            </head>
            <body class="c">
            "
            Bottom
            "</body>
            </html>
            "
            Top
            "s"
            Paste
            ".htm"
            SelectToTop
            Cut
            SaveAs "^c"
            CloseFile
            EndLoop
            Top
            CopyFilePath
            CloseFile NoSave
            Open "^c"
            ClearClipboard
            Clipboard 9
            ClearClipboard
            Clipboard 0
            UnixReOn

            Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style - see Advanced - Configuration - Find - Unix style Regular Expressions. UnixReOn/UnixReOff modifies this setting.

            The MainMacro modifies the source file temporarily. It closes the source file at the end of execution without saving it and reopens it. If you don't need the reopening, you can remove the 2 lines:

            CopyFilePath
            Open "^c"

            OK! I hope you look into my macros and learn something. Next time you should do your job by yourself or I will have to ask for a financial donation.
            Best regards from an UC/UE/UES for Windows user from Austria