It is currently Mon Jul 22, 2024 2:22 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: String comparisons
PostPosted: Sat Feb 08, 2014 6:38 am  (#1) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
Please how do I compare two strings in an "if" structure?

-strcmp seems not to be working:
[john@asusarch ~]$ gmic -if {-strcmp "one","one"} -echo yes -else -echo no -endif
[gmic]-0./ Start G'MIC parser.
[gmic]-0./*if/ no
[gmic]-0./ End G'MIC parser.


if equality (ie ==) fails too:
[john@asusarch ~]$ gmic -if {"one"=="one"} -echo yes -else -echo no -endif
[gmic]-0./ Start G'MIC parser.
[gmic]-0./ *** Error in ./ *** Item substitution '{expression}': Invalid item 'one' in specified expression 'one==one...'.

[gmic]-0./ Abort G'MIC instance.

[gmic] *** Error in ./ *** Item substitution '{expression}': Invalid item 'one' in specified expression 'one==one...'.


[john@asusarch ~]$


Any ideas?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: String comparisons
PostPosted: Sat Feb 08, 2014 6:59 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
There are two special string comparisons operator to do this kind of operation :
Quote:
{str1'=='str2}
and
Quote:
{str1'!='str2}

gmic -if {{mary'='mary}&&{james'!='mary}} -e TRUE -else -e FALSE -endif


Or course, if your strings have spaces in them, you need to double-quote them as well.

gmic -if {{"mary is nice"'='"mary is nice"}&&{"james is nice"'!='"mary is nice"}} -e TRUE -else -e FALSE -endif


The command -strcmp is actually one older command that was used when these special string comparison operators were not defined in G'MIC.
It can be used like this, if your strings have spaces in them :

gmic -if @{"-strcmp \"mary is nice\",\"mary is nice\""} -e TRUE -else -e FALSE -endif


Hope this helps.


Top
 Post subject: Re: String comparisons
PostPosted: Sat Feb 08, 2014 10:35 am  (#3) 
Offline
GimpChat Member

Joined: Feb 08, 2014
Posts: 26
It's working! Thanks a lot!


Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) String Art Plug-in

26

No new posts Attachment(s) Columbine String Art.

6

No new posts Attachment(s) String Trussed Dalia

5

No new posts Attachment(s) Free – Selection Tool – Stopping the String

4

No new posts Attachment(s) GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugin

87



* Login  



Powered by phpBB3 © phpBB Group