Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem to define a string
#1
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


Attached Files Image(s)
   
Reply


Messages In This Thread
Problem to define a string - by Petequero - 05-20-2018, 11:25 AM
RE: Problem to define a string - by Kevin - 05-21-2018, 03:35 PM

Forum Jump: