Relevance duplication cleanup with "it"

Can someone please help me replace the duplication of the file name in these relevance statements? I have tried but can’t seem to get my “it” clauses to work properly.

Source data is an ini file that contains the following text:

[STEP3]
Description=CCD Folder
Source=f:\backup\data\ccd
Dest=%DEST%\backup\data\ccd
Overwrite=2

The following relevance statements work, but as you can see I have the file path duplicated.

1: ( Returns “True” with the test ini )

exists variable whose (it starts with ((it & "]") of unique value of (preceding texts of firsts "].Description=CCD Folder" of it) of variables of file "C:\Temp\test.ini" & ".Source=")) of file "C:\Temp\test.ini"

2: ( Returns “f:\backup\data\ccd” with the test ini )

following text of first "=" of variables whose ( it starts with ((it & "]") of unique value of (preceding texts of firsts "].Description=CCD Folder" of it) of variables of file "C:\Temp\test.ini" & ".Source=")) of file "C:\Temp\test.ini" | "Missing"

So does [STEP3] change and is not a constant?

Can you describe what the 2 relevance statements do in english?


Does this work for the 2nd option?

following texts of firsts "=" of variables whose (it contains ".Source=") of files "C:\Temp\test.ini"

or:

keys "Source" of sections "STEP3" of files "C:\Temp\test.ini"

or:

unique values of keys "Source" of sections ("";"STEP1";"STEP2";"STEP3";"STEP4") of files "C:\Temp\test.ini"

or:

unique values of keys "Source" of sections ( unique values of (preceding texts of firsts "]" of following texts of firsts "[" of it) of variables of files "C:\Temp\test.ini" ) of files "C:\Temp\test.ini"

q:unique values of (preceding texts of firsts "]" of following texts of firsts "[" of it) of variables of files "C:\Temp\test.ini"
A: STEP3
T: 0.186 ms

References:

Sure, here’s some more context. I have an ini that’s controlled by a vendor, so I can’t change the overall format without jumping through hoops and waiting weeks for them to get around to it. So I have to deal with what I have.

The [STEP3] ini snippet I provided is one of several “[STEPX]” sections of their ini. The section I need to know about contains “Description=CCD Folder”, but I can’t assume that it is always going to be in [STEP3]. It may be in some other [STEPX] section.

So this part of each of the relevance sniippets I posted returns a [STEPX] string - e.g. with the sample ini it would return [STEP3].

(it & "]") of unique value of (preceding texts of firsts "].Description=CCD Folder" of it) of variables of file "C:\Temp\test.ini"

Then I combine that with “.Source=” to equate to something like this, again where in this particular example STEPX is STEP3:

following text of first "=" of variables whose ( it starts with ("[STEPX]" & ".Source=")) of file "C:\Temp\test.ini"

That relevance returns the path for the Source key, i.e. “f:\backup\data\ccd”.

The relevance statements I have are for two scenarios, where for the first I am checking if the Source variable exists and the second I am checking the value. In reality I am probably only going to use the second one. They both work, I just can’t seem to get the it and parentheses placed right to get rid of the first file “C:\Temp\test.ini” instance.

1 Like

This will get you the sources & descriptions that appear in the file:

variables whose (it contains ".Source=" OR it contains ".Description") of files "C:\Temp\test.ini"

Now, just need to get the source where the description is what is desired.

–This (doesn’t) work:–

item 0 of (it, preceding texts of firsts "]" of following texts of firsts "[" of it whose(it contains ".Description=CCD Folder") ) whose(item 0 of it contains ".Source=" AND item 0 of it contains ( "[" & item 1 of it & "]" ) ) of variables whose (it contains ".Source=" OR it contains ".Description=") of files "C:\Temp\test.ini"

I tried out the example with item0 / item1, but am getting “Singular expression refers to nonexistent object”. Can’t seem to figure out where it is breaking though.

1 Like

This works:

(it as trimmed string) of (following texts of firsts ".Source=" of item 1 of it) of ( variables whose(it contains ".Description=CCD Folder") of it, variables whose(it contains ".Source=") of it ) whose( (preceding text of first "." of item 0 of it) = (preceding text of first "." of item 1 of it) ) of files "C:\Temp\test.ini"

This gets all of the variables with Description=CCD Folder and all of the Source variables, then filters out all of the Source variables that don’t match the section of the Description=CCD Folder variable.

1 Like

Thanks again James! Very nice.

1 Like

Using your provided text.ini the relevance I came up with seems to be 3 times more efficient. I think it would be even more so with larger ini files.

It probably won’t make too much of a difference, but it is interesting to see how many different ways you can get to the same result.

Here is one I’m struggling to simplify: :smile:

names of items 0 of ( it, name of it, (it as string) of (( maximum of (name of it as version) of it whose(name of it contains "10.x") of fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it) ) ; ( maximum of (name of it as version) of it whose(name of it contains "11.x") of fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it) )) ) whose(item 1 of it contains item 2 of it) of fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it)

It uses the following Session Relevance 3 times: :confused:

fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it)

References:

1 Like

I don’t have a console available right now, will try later this week if I can. I tend to try to use “bes fixlet set”. So it would look something like the following

names of items 0 of ( it, name of it, (it as string) of (( maximum of (name of it as version) of it whose(name of it contains "10.x") of elements of it ; ( maximum of (name of it as version) of it whose(name of it contains "11.x") of elements of it) whose(item 1 of it contains item 2 of it)))) of set of fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it)

something bad with “direct” variant ?

names of items 0 of 
( it, name of it, (it as string) of 
(
    ( maximum of (name of it as version) of it whose(name of it contains "10.x") 
of it
    ) ; 
    ( maximum of (name of it as version) of it whose(name of it contains "11.x") 
of it )
)
) 
    whose(item 1 of it contains item 2 of it) 

of ( fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it) of bes sites whose("Updates for Windows Applications" = name of it) )

at least fixlet debuger points “it” to correct set of values

@JasonWalker : This doesn’t work. The whose clause is in the wrong place it seems, and I think there are other issues.

@VitaliL : This doesn’t work either. Gives Error: Singular expression refers to nonexistent object. .

I think I tried an approach similar to this already. The maximum won’t work this way. It might work if it was on a fixlet set rather than a plural fixlet result, but I’m not certain of that.

(item 0 of it) of 
((elements of it, maximum of ((elements of it) whose (it contains "11.x") as version)| "0.0.0" as version, maximum of ((elements of it) whose (it contains "10.x") as version)| "0.0.0" as version)
of set
of names
of fixlets whose(name of it contains "Acrobat" AND exists (name of it as version) AND name of it does not contain " (Superseded)" AND globally visible flag of it)
of bes sites whose("Updates for Windows Applications" = name of it))
whose (item 0 of it contains item 1 of it as string or item 0 of it contains item 2 of it as string )

Nice work!

I tried to do something like that, but I kept getting an error. I was missing the | "0.0.0" as version part. I tried using options like NOTHINGS or NULL but that didn’t work. I never thought to create a “fake” version like that.