Gimp-Forum.net
Problem to define a string - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: Problem to define a string (/Thread-Problem-to-define-a-string)



Problem to define a string - Petequero - 05-20-2018

Hello guys, 



I have just solved my probleme of saving file (see thread file-png-save-defaults) by replacing one part of the code for another that I found on internet. 

I would like to understand why the one I use at fist didn't work. 



That is a problem of string building. Below in the code, two different way to build a string (which is eventually insert in the save file-png-save-defaults function).

The option number one is working. The option number 2 is not. Do you have any idea why ? 


Code:
(let*  (
        (destinationPath "C:/Users/Dav/Desktop/File")
        (filename "C:/Users/Dav/Desktop\\image.png")

;;;;;;;;;;;;;;;;;; Option number 1, which is working ;;;;;;;;;;;;;;;;;;;;;;;;;;
     (outputFilenameNoExtension
            (string-append
              (string-append destinationPath "/")
              (unbreakupstr
                (reverse
                  (cdr
                    (reverse
                      (strbreakup
                        (car
                          (reverse
                            (strbreakup filename "\\")
                          )
                        )
                        "."
                      )
                    )
                  )
                )
                "."
              )
            )
          )
          (outputfilename1 (string-append outputFilenameNoExtension ".png"))  ;add the new extension
          
;;;;;;;;;;;;;;;;;;;;; Option number 2, which is not working ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          
              (outputfilename2
                    (string-append
                        (string-append 
                            destinationPath "/") ;chemin/
                                (cadr (strbreakup filename "\\")) ;image.png
                    )
                    
            )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; an then compare (0 means the same) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

            (comparison (number->string (strcmp outputfilename1 outputfilename2)))
        )

;;;;;;;;;;;;;;;;;;;;; Print on console ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        (gimp-message (string-append "Option 1 (working)     :" outputfilename1))
        (gimp-message (string-append "Option 2 (not working) :" outputfilename2))
        (gimp-message (string-append "Comparison (0 means the same) :" comparison))
)

And the crual thing is that the function strcmp, which compare string, display 0, meaning that it is the same string. 
Why then one of them isi working, but the other one is not ?

Thanks in advance for any feedback. 

David


RE: Problem to define a string - Kevin - 05-21-2018

I don't see your problem - the code you have posted is giving the same string for both methods.

That would lead me to suspect that the problem is with your script not producing the expected output from the file-glob process.