Announcement

Collapse
No announcement yet.

Issues with "Actions" and window minimization

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

  • Issues with "Actions" and window minimization

    Hello. Help to solve, please, 2 problems.​

    1 problem:​
    In the project settings I enabled the "Backup patched files" - I want the file backups to be stored exactly in the target folder. But I also would like this folder to be deleted after the successful completion of the patch. I did not understand which command to specify in the Actions section and did not understand in which section - "On Post Patch" or "On Shutdown".​

    2 problem:
    How to add a minimize window button to the top right corner of the patch window?​

    Help me please. Thanks in advance for your advice.​

  • #2
    1) For deleting all files in a folder and the folder itself, you can use Folder.DeleteTree(). I would perform the cleanup before the "Patch Successful" screen is shown, in other words, in the On Post Patch event.

    2) There is no option for adding a minimize button in the title bar of the application.

    Ulrich

    Comment


    • #3
      Originally posted by Ulrich View Post
      1) For deleting all files in a folder and the folder itself, you can use Folder.DeleteTree(). I would perform the cleanup before the "Patch Successful" screen is shown, in other words, in the On Post Patch event.
      Thank you. Could you clarify the argument of the Folder.DeleteTree function?​ I wrote like this, but it doesn't work - Folder.DeleteTree("%AppFolder%\Backup")
      This is the only line in the On Post Patch section.​ Where did I go wrong? Help me please. Thank you in advance.​

      Comment


      • #4
        If you do not have the time to read the product documentation, this might help.

        Ulrich

        Comment


        • #5
          Originally posted by Ulrich View Post
          If you do not have the time to read the product documentation, this might help.

          Ulrich
          Hello, Ulrich. I have dealt with this issue.​ I wrote the following command in the "On Post Patch" section​ - Folder.DeleteTree("%AppFolder%\\Backup", nil);
          Now there is one more question. How to organize the display of free space on %SourceDrive% on the "Ready to Patch" screen?​ I think that this should be done in the "On Preload" section.​ I set this variable​: Free_Space = Drive.GetFreeSpace("%SourceDrive%​"). Then I display "Ready to Patch" like this: % Free_Space%. But it shows up as %Free_Space%​. I assume that this value should be converted to a string, but I do not understand how to do this.​ And I would like to display this value in gigabytes, so it must be divided by 1024 before being converted to string.​ You do not think that I'm too lazy to read the documentation. It’s just that I don’t understand English well and often use a translator, but it distorts the translation of some terms and I stop understanding the instructions.​

          Comment


          • #6
            I wrote the following command in the "On Post Patch" section​ - Folder.DeleteTree("%AppFolder%\\Backup", nil);
            This is incorrect. If you follow the post I linked in my previous reply, you see that you need to expand Session Variables before you can treat the contents as strings. In other words, you need to write the code as

            Code:
            Folder.DeleteTree(SessionVar.Expand("%AppFolder%\\Backup"), nil);
            How to organize the display of free space on %SourceDrive% on the "Ready to Patch" screen?​ I think that this should be done in the "On Preload" section.​ I set this variable​: Free_Space = Drive.GetFreeSpace("%SourceDrive%​"). Then I display "Ready to Patch" like this: % Free_Space%. But it shows up as %Free_Space%​.
            "Free_Space" is not the same as "%Free_Space%". You assign a value to Free_Space and then attempt to display another variable, expecting to show the same contents. This is not how this works. Session Variables are explained in the product documentation. If you want to assign a value into a Session Variable, then you need to use SessionVar.Set(), not an assignment "=".

            Code:
            SessionVar.Set("%Free_Space%") = Drive.GetFreeSpace("%SourceDrive%");
            And I would like to display this value in gigabytes, so it must be divided by 1024 before being converted to string.​
            There is a action for formatting sizes, see String.GetFormattedSize() for this. However, this action does not handle sizes > 1TB correctly. Therefore, define a custom function such as this:

            Code:
            function String.GetNewFormattedSize(nFreeSpaceInMB)
                if ((nFreeSpaceInMB / 1048576) > 1) then
                    return string.format("%0.2f TB", nFreeSpaceInMB / 1048576);
                elseif ((nFreeSpaceInMB / 1024) > 1) then
                    return string.format("%0.2f GB", nFreeSpaceInMB / 1024);
                else
                    return string.format("%d MB", nFreeSpaceInMB);
                end
            end
            You could then use this function like this:

            Code:
            local nSize = Drive.GetFreeSpace("%SourceDrive%");
            SessionVar.Set("%Free_Space%", String.GetNewFormattedSize(nSize));
            which allows you to display the result with %FreeSpace% on the screen, as long as this code was run before the screen was shown.

            However, I think that you have another error here. %SourceDrive% holds the drive from where the patch is being run. This could be any drive, such a removable USB drive, for example. The free space on this device is irrelevant for applying a patch. What you really need to know is the free space on the target drive, where the application to be patched resides.
            At this point, you already know that the application to be patched can be found in the path stored in %AppFolder%. You want to know the free space on that drive, not the source drive. This would make much more sense:

            Code:
            local tPath = String.SplitPath(SessionVar.Expand("%AppFolder%")) ;
            local nSize = Drive.GetFreeSpace(tPath.Drive);
            SessionVar.Set("%Free_Space%", String.GetNewFormattedSize(nSize));​
            Ulrich

            Comment


            • #7
              Originally posted by Ulrich View Post

              This is incorrect. If you follow the post I linked in my previous reply, you see that you need to expand Session Variables before you can treat the contents as strings. In other words, you need to write the code as

              Ulrich
              Thank you very much, Ulrich, for such a detailed answer.

              I tried to add the solution you suggested, but when I run the patch, I get this error window:​ "On Preload, Line 3: attemp to all field 'GetNewFormattedSize' (a nil value)".

              After closing this window, the patch starts, but still the size of the free space is not displayed, but the inscription is shown -​ %Free_Space%

              Here is what I have in the "On Preload" section:​

              Code:
              01  -- These actions are performed before the screen is shown.
              02  local nSize = Drive.GetFreeSpace("%SourceDrive%");
              03  SessionVar.Set("%Free_Space%", String.GetNewFormattedSize(nSize));​
              I thought maybe you made a mistake and instead of String.GetFormattedSize wrote GetNewFormattedSize and put String.GetFormattedSize instead of GetNewFormattedSize.​
              The error before loading the patch has disappeared, but now the patch shows -1 bytes of free space))​

              Help me, please, Ulrich.

              Comment


              • #8
                Hello, the error you mention implies that you did not define the custom function as I indicated above. You need to define the function before the first call, and this can be done at the start of the event script itself, or by adding the definition to the Global Functions of your project resources.

                At this point, I believe that it is clear that the product fits your needs, so you may want to get a license for it. Once you have a license for Visual Patch, you can associate your user forum account with your customer account, or you can place future questions in the Customer Portal, and I will be happy to assist further if needed.

                Ulrich

                Comment


                • #9
                  Originally posted by Ulrich View Post
                  Hello, the error you mention implies that you did not define the custom function as I indicated above. You need to define the function before the first call, and this can be done at the start of the event script itself, or by adding the definition to the Global Functions of your project resources.

                  At this point, I believe that it is clear that the product fits your needs, so you may want to get a license for it. Once you have a license for Visual Patch, you can associate your user forum account with your customer account, or you can place future questions in the Customer Portal, and I will be happy to assist further if needed.

                  Ulrich
                  Hello Ulrich. I just can’t buy Visual Patch 3.8. This is what they show me after I click on the Buy button and they don’t let me through any further.​



                  Click image for larger version

Name:	FireShot Capture 1050 - Attention Required! - Cloudflare - store.indigorose.com.png
Views:	18
Size:	57.0 KB
ID:	310709

                  In order not to waste time while this problem is solved, can you tell me how to make the drive letter appear without a trailing colon when using %SourceDrive%? I want the result of %SourceDrive% not to be F:, but just F.​ Thank you in advance for your cooperation.​

                  Comment


                  • #10
                    Hello, access is currently blocked due to sanctions against the country where you are located in. This is completely out of our control, as Cleverbridge is located in Germany, and obeys EU regulations.

                    You can try to place your order on the ComponentSource web site.

                    For removing specific trailing chars from a string, or extracting substrings, you can use the String.TrimRight(), String.Left() or String.Mid() actions. Any of these actions can be used for the task you described.

                    Ulrich

                    Comment


                    • #11
                      Originally posted by Ulrich View Post
                      Hello, access is currently blocked due to sanctions against the country where you are located in. This is completely out of our control, as Cleverbridge is located in Germany, and obeys EU regulations.

                      You can try to place your order on the ComponentSource web site.

                      For removing specific trailing chars from a string, or extracting substrings, you can use the String.TrimRight(), String.Left() or String.Mid() actions. Any of these actions can be used for the task you described.

                      Ulrich
                      Thank you very much, Ulrich. Their support asked me to write them an email, which I did.​

                      But regarding my question it is not entirely clear to me...I understand that I need to do something like the following:

                      Code:
                      Source_Drive = SessionVar.Expand("%Source_Drive%");
                      Source_Drive2 = String.Left(SourceDrive, 1);
                      SessionVar.Expand("%Source_Drive2%", Source_Drive2);​
                      I want %Source_Drive2% to store the drive letter, but without the colon at the end. But somewhere I make a mistake and I don’t understand how to fix it. Help me please.​

                      Comment


                      • #12
                        Code:
                        Source_Drive = SessionVar.Expand("%Source_Drive%");
                        Source_Drive2 = String.Left(SourceDrive, 1);
                        SessionVar.Set("%Source_Drive2%", Source_Drive2);​​

                        Comment


                        • #13
                          Code:
                          SessionVar.Set("%MySourceDrive%", String.Left(SessionVar.Expand("%SourceDrive%"), 1));
                          Ulrich

                          Comment


                          • #14
                            Originally posted by Ulrich View Post
                            Code:
                            SessionVar.Set("%MySourceDrive%", String.Left(SessionVar.Expand("%SourceDrive%"), 1));
                            Ulrich
                            Thank you very much, Ulrich

                            I tried to buy the Visual Patch on the site you indicated, but they also refused me there. Is there really no way I can buy this product? My trial version had already expired and I had to install it on another computer to continue working.​

                            Comment


                            • #15
                              The only way I see in the current political situation is placing the order from outside the sanctioned country. If you have a contact who lives elsewhere, this person could place the order for you, and then forward the information so you can adjust the customer account with your own info, so you can log into the Customer Portal, download the software, and submit technical support requests when needed.

                              Ulrich

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎