Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 8137 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

can i sum list of binary strings?

I have a ten character string in each record made of one and zero (i.e. 1001011101) I would like to sum a group of these and find out where the zero are.

10010

00100

10000

00011

------

10111

I guess i am trying to find availiable spaces so with the above example i know position two is available. I know I can create a field for each postition and then max those relationships but I am curious if there is a trick.

It is like when a single digit can conclude a group of three binary states, so when states 1-3 are identified as 4,2,1 then digits 0-7 can represent any combination of the three positions. So number 3 would represent '011', and 5 = '101'

(i wish i took more math)

Posted

You are not really talking about summing the values in any normal mathematical sense, since it appears from your explanation that you want to treat each position (or 'column') separately, whereas in all numbering systems are by definition hierarchical and column values are interdependent.

To break the interdependence I suspect that you are going to have to bite the bullet and break out the digits into ten separate fields and sum those fields separately.

Note, however, that if you use a self-join, the groups of values being summed will be defined by the relationship and will operate independantly of the found set. If you want to perform finds and then view a result for the found set you will need to use Summary Fields and unstored calcs based on them (eg to convert the ten results to a boolean form and concatenate them to arrive at a composite string for display).

Posted

This is what I've already posted you on other forum:

Well if you insist.

You'll need an aux field an value list based on that field.

So, assuming you have field binstring, create an calc field (indexed, result text) as

calc=Substitute(Position(binstring,"0",1,1) & Position(binstring, "0", 1, 2) & Position(binstring, "0", 1, 3) & Position(binstring, "0", 1, 4) & Position(binstring, "0", 1, 5) & Position(binstring, "0", 1, 6), "0", "")

Now define an value list "FreePos" as use values from field calc and define another calculation field (unstored, text)

result=

(PatternCount(listItems,"1") = total) &

(PatternCount(listItems, "2") = total)&

(PatternCount(listItems,"3") = total) &

(PatternCount(listItems, "4") = total) &

(PatternCount(listItems, "5") = total) &

(PatternCount(listItems, "6") =total )

Parenthesis in above calc are required

where total=WordCount(listItems)

and

listItems=ValueListItems(Status(CurrentFileName), "FreePos")

Also, bear in mind that if you extend the above calculation on more than 9 slots you'll have to use letters in place of digits for positions from 10 and above.

There could be also some refreshing issues if you change allready existing fields.

1 more thing, the ones in result fiield present free slots so you might have to invert it to achieve the form you want:

resAdjusted=Substitute(Substitute(Substitute(

result,"0","?"),"1","0"),"?","1")

Dj

smirk.gif

This topic is 8137 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.