I would like to know if FMP could transform, say 272592 in 6 fields each with a single number: 2 - 7 - 2 - 5 - 9 - 2
I got it.
Your recommendation solved the issue!
That's exactly as you said.
Thank you very much.
Is the number ALWAY six digits long??
Set Variable ($fieldNames ) = List ( table::field1 ; table::field2 etc
Set Variable ($numberAsString) = GetAsText ( your number )
Set Variable ($i) = $i + 1
Set Variable $it = Middle ( $numberAsString ; $i ; 1 )
SetFieldByName ( GetValue ( $fieldNames ; $i ) -> $it
I would like to get the 6 digit number ( 272592) in 6 number fields of 1 single number each.
First field: 2
Second field: 7
and so on
You could create 6 different fields, e.g. calculation fields, with a formula along the lines of what jrenfrew mentioned above:
Middle ( Number ; 1 ; 1 )
Middle ( Number ; 2 ; 1 )
Middle ( Number ; 3 ; 1 )
I am however curious as to what the purpose of this is? Maybe there's another way of achieving it (or maybe not)?
I will try.
The way your question is phrased it appears that you have a single field containing a six digit number and you want to parse out each digit into a different field. If this is correct then the next question becomes, are all 7 fields in the same record, or across multiple records?
Yes! I have a single field containing a six digit number, as you say.
And yes: I want to parse out each digit into a different field, exactly as you say.
And the 7 fields are in the same record.
You understood my problem perfectly
I'm waiting onefish answer
I'm waiting your follow on
eduardohomem wrote: I want to parse out each digit into a different field,
I want to parse out each digit into a different field,
Using the Middle() function as shown above should work. But the question is why do you need this? There may be a simpler way to achieve your goal.
OK, then what David Wikström has posted is where I was headed (he posted while I was typing). I will offer a slight variation though. The additional 6 fields can be number fields with auto enter definition using the calculations (as opposed to calculation fields). If you add these fields to a table containing existing records and 6 digit values, then you would need to run a short script using 'replace field contents' and replace the 6 digit number field contents with the existing value. This will trigger the auto enter calculations in the 6 new fields in each existing record. It will happen automatically for new records (no script necessary).
Your 6 autoenter fields can be
Mod ( yourField ; 10 ) /1
Mod ( yourField ; 100 ) /10
Mod ( yourField ; 1000 ) /100
Here's how I would tackle it. A number field, and a set of calculated fields that pull their respective position. Enter a number and the calculations take care of the rest.
Thank you techt.
Unfortunately, my FMP version is 8 and so I'm not able to open your attachement.
I dont know if my FMP 8 version is able to do what you recommend; a set of calculated fields that pull their respective position. If you tell me step by step the procedure, maybe I will be able to do it.
This would work as long as the base data is not a code, like zip codes, that can start with a 0 or a series of 0s.
No worries, I've attached a couple of screen shots. I do highly recommend upgrading. There's tons of new features and capabilities that you're missing out on.
You're very welcome. Glad I was able to help.
Retrieving data ...