Announcement

Collapse
No announcement yet.

Write info To A Text File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write info To A Text File

    Hi...

    I am after a bit of help in writing some info to a .txt file.

    I have made a quick example of what I have so far but what I want to do is take some information from a paragraph

    C:\Users\Malcs\Desktop\Test\[en-gb]_en-gb_windows_10_consumer_editions_version_20h2_updat ed_feb_2021_x64_dvd_1b81c45e.svf
    Take its file name
    [en-gb]_en-gb_windows_10_consumer_editions_version_20h2_updat ed_feb_2021_x64_dvd_1b81c45e.svf
    and save as a .text file named as the file name, above.

    I have a button

    Code:
    PG_Image = Paragraph.GetText("Paragraph1");
    
    
    bFileParts = String.SplitPath(PG_Image);
    bDrive = bFileParts.Drive;
    bFolder = bFileParts.Folder;
    bFileName = bFileParts.Filename;
    bFileExtension = bFileParts.Extension;
    bFullFileName = bFileName..bFileExtension;
    bCurrentFolder = bDrive..bFolder
    
    
    --TextFile.WriteFromString(bCurrentFolder .. "\\Image_Name.txt", bFileName, false);
    
    TextFile.WriteFromString(bCurrentFolder .. bFileName, bFileName, false);
    
    
    --File.Open(bCurrentFolder .. "\\Image_Name.txt", "", SW_SHOWNORMAL);
    As it stands the a file is created but not as a .txt and if I put
    bFileName.txt
    I get errors.

    I dont know how to write the script so I end up with

    [en-gb]_en-gb_windows_10_consumer_editions_version_20h2_updat ed_feb_2021_x64_dvd_1b81c45e.txt
    Hoping somebody can help me out here...

    Cheers

    Example.apz

  • #2
    Check the attached apz

    Changed below code so it will create txt file and name it with bFileName
    TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "Test Script", false);

    Or you can use "shell getfolder" to get the user desktop path
    Shell.GetFolder(SHF_DESKTOP);
    Attached Files

    Comment


    • #3
      Example-string.apz

      Comment


      • #4
        Originally posted by miliachref View Post
        [ATTACH]n306798[/ATTACH]
        Beautiful...

        Thanks for that, really appreciate it.

        Comment


        • #5
          I have this working a treat in my project.

          Let me explain why I wanted to do this.
          Once I have downloaded the images, checked and verified their checksum values I always made a text document adding all the relative information of the file, image name, the checksum values and time and date. Never took that long to do to be honest but now it does it automatically.

          I have been testing this, it works really well and I am well happy with the outcome.

          Thanks very much miliachref for your input.

          This is my script

          Code:
          -- Save info to a text document
          ImageInput = Input.GetText("ImageInput");
          ImageName = Paragraph.GetText("ImageName");
          
          Month = System.GetDate(DATE_FMT_MONTH);
          Year = System.GetDate(DATE_FMT_YEAR);
          Date = System.GetDate(DATE_FMT_EUROPE);
          Hour = System.GetTime(TIME_FMT_MIL);
          
          KnownSHA1ChecksumValue = Paragraph.GetText("KnownSHA1ChecksumValue");
          CalculatedSHA1ChecksumValue = Paragraph.GetText("CalculatedSHA1ChecksumValue");
          
          bFileParts = String.SplitPath(ImageInput);
          bDrive = bFileParts.Drive;
          bFolder = bFileParts.Folder;
          bFileName = bFileParts.Filename;
          bFileExtension = bFileParts.Extension;
          bFullFileName = bFileName..bFileExtension;
          bCurrentFolder = bDrive..bFolder
          
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", bFileName, false);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\n" ..ImageName, true);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\nDownloaded  - " ..Month.."/"..Year, true);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\nKnown SHA1 Checksum Value = " ..KnownSHA1ChecksumValue, true);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\nCalculated SHA1 Checksum Value = " ..CalculatedSHA1ChecksumValue, true);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\nSHA1 checksum checked and verified - "..Date.." at "..Hour , true);
          TextFile.WriteFromString(bCurrentFolder..bFileName ..".txt", "\r\n\r\nVeriHash" , true);
          -- End Of - Save info to a text document
          Not sure if all that info can be written in one line but I wont worry about that.

          Cheers...

          P.S.

          Getting very near in asking how to incorporate a progress bar, so if you know how to do these and you're reading this please keep an eye out on a future post asking for help from me.

          Comment


          • #6
            Since what your doing would be way two fast for any progressbar you would have to fake it
            Plugins or Sources MokoX
            BunnyHop 2021 Here

            Comment


            • #7
              Originally posted by kingzooly View Post
              Since what your doing would be way two fast for any progressbar you would have to fake it
              Thanks for the interest but that is not what I want my progress bar for.

              I am making a checksum calculator, verifier.

              It takes between 20 seconds to 1 minute depending on image size. I know this is very little detail to go on but what do those time frames sound like ? Slow enough for a progress bar ?

              I will be starting a new thread on the matter...

              Cheers though..

              Comment


              • #8
                Then use the search no need to create a new post for it as not really many active people anymore, there are loads of progress bar examples
                Plugins or Sources MokoX
                BunnyHop 2021 Here

                Comment


                • #9
                  Originally posted by kingzooly View Post
                  Then use the search no need to create a new post for it as not really many active people anymore, there are loads of progress bar examples
                  Yep... I have got a couple of those. Just cant get my head round it.

                  Think I will make a new post all the same and cross my fingers...

                  Comment

                  Working...
                  X