Tapatalk

Lorem Ipsum Generator / Random text

Lorem Ipsum Generator / Random text

1581
Power UserPower User
1581

    Oct 30, 2013#1

    Out in the Web (and in MS Word) there are features which generates "random text" (lorem ipsum generator). Is there a feature or an external interface in UE?

    Thanks

    Peter
    UE 26.20.0.74 German / Win 10 x 64 Pro

    6,685587
    Grand MasterGrand Master
    6,685587

      Oct 30, 2013#2

      Download from Lorem Ipsum Generator: grab the javascript the JavaScript file loremipsum.js.

      Open this JavaScript file in UltraEdit and replace the 10 occurrences of document.write by UltraEdit.activeDocument.write

      Append at end of the script file the following 3 lines:

      Code: Select all

      UltraEdit.newFile();
      var nWords = UltraEdit.getValue("How many words should have the paragraph?",1);
      loremIpsumParagraph(nWords);
      Save the script file and execute it with Scripting - Run Active Script.

      With removing the first line the script writes the strings into active file at current caret position.

      The script could be also modified to create the string first in clipboard and paste it at once into the active file or in a string variable written at once into active file.
      Best regards from an UC/UE/UES for Windows user from Austria

      1581
      Power UserPower User
      1581

        Oct 30, 2013#3

        Thousand roses to you (again .. :)

        Peter

          Dec 16, 2014#4

          Hi!

          There is this code in the file:

          Code: Select all

          // just switch language like this! You can also do this in a script block on the page. 
          var loremLang = latin;
          I tried to replace with:

          Code: Select all

          // just switch language like this! You can also do this in a script block on the page. 
          var loremLang = UltraEdit.getString("Sprache wählen: \nlatin - swedish - zufall",1);
          The result is that not the latin words are used, but the word "latin" is used to create

          Code: Select all

          L  i i t l i i i l l.
          What happened here?

          Peter
          UE 26.20.0.74 German / Win 10 x 64 Pro

          6,685587
          Grand MasterGrand Master
          6,685587

            Dec 16, 2014#5

            Hi Peter!

            What you had tried can't work as you had assigned a string entered by user of the script to a variable which is designed for being a pointer to an array of strings containing the words for text generation.

            The script code var loremLang = latin; assigns to variable loremLang the array latin as defined 6 lines above this code line. Another available array is swedish. There are no more arrays with words for other languages available.

            See the script in attached ZIP file how to code language selection between Latin and Swedish correct.

            I have made some more small changes and additions to improve output of generated text.
            ue_loremipsum.zip (4.96 KiB)   130
            This ZIP file contains loremipsum.js written by Fredrik Bridell edited for usage with UE / UES.
            Best regards from an UC/UE/UES for Windows user from Austria

            1581
            Power UserPower User
            1581

              Dec 16, 2014#6

              Hi Mofi

              thanks - it works fine :!:

              I only removed the new

              Code: Select all

              UltraEdit.newFile();
              Peter
              UE 26.20.0.74 German / Win 10 x 64 Pro

              6,685587
              Grand MasterGrand Master
              6,685587

                Dec 17, 2014#7

                Hi Peter!

                You have hopefully changed also

                Code: Select all

                if (nWords < 1)
                {
                   UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
                }
                else
                to

                Code: Select all

                if (nWords > 0)
                as this code just closed the new file without saving if entered number was lower than 1.

                I'm sure you don't want to close active file without saving on entering by mistake for example value 0 for number of words.
                Best regards from an UC/UE/UES for Windows user from Austria

                1581
                Power UserPower User
                1581

                  Dec 17, 2014#8

                  Mofi wrote:...You have hopefully changed also...
                  :oops: :oops:

                  Peter
                  UE 26.20.0.74 German / Win 10 x 64 Pro