ZBrushCentral

ZScript [LoopExit] won't exit WHY

Below is a loop for a zscript I’m doing, it’s supposed to be a simple loop with a loop exit when the foldername for the active subtool doesn’t match. I have debuged with notes and even though it displays both variables accurately not matching, the loop continues and doesn’t activate the else in the if statement. Please someone call me an idiot and explain why this is.

    [VarDef, targetFolder, [SubToolGetFolderName]] //get folder name
[VarDef, initSubTool, [SubToolGetActiveIndex]] //get initial subtool index #
[VarDef,targetSubtools(50),0] // makes a 50 long list to store the subtools within the target folder
[VarDef, curFolderItem,0] //initializes the slot tracking for the target subtools list
[VarSet, targetSubtools(0),initSubTool] //stores the initial subtool as the first in the list

[VarAdd,curFolderItem,1]//increment up to switch to next slot in the targetSubtools list
//[SubToolSelect,targetSubtools(curFolderItem)]//go to next subtool in folder
[SubToolSelect,[SubToolGetActiveIndex]+1]//go to next subtool in folder

[Loop,49,
    [Note, [SubToolGetFolderName]]
    [Note, targetFolder]
    [Note, curFolderItem]
    [If,[SubToolGetFolderName] != targetFolder,
        [Note, "doesn't match folder"]
        [Note, [SubToolGetFolderName]]
        [LoopExit]
    ,
        [VarSet, targetSubtools(curFolderItem), [SubToolGetActiveIndex]]
        [VarAdd,curFolderItem,1]//increment up to switch to next slot in the targetSubtools list
        //[SubToolSelect,targetSubtools(curFolderItem)]//go to next subtool in folder
        [SubToolSelect,[SubToolGetActiveIndex]+1]//go to next subtool in folder
    ]      
]

Further troubleshooting this, I found that the If statement condition doesn’t really accept or properly compare strings. When switching to the index number for the folder it properly compared.

Try

[If,([StrFind,“AAA”,“BBB”]==0)&&([StrFind,“BBB”,“AAA”]==0), … , … ]

to compare two strings.

Not the “==” .