August 20, 200421 yr Hi all, I'm sure this is REALLY simple but I've managed to fuse my brain. Can you help? In a calculation field I want to create an expression 3 * "a" which would produce "aaa" or 5 * "ask" which would produce "askaskaskaskask" Can you help? Thanks G
August 20, 200421 yr Substitute( Right( 10 ^ number; number ); "0"; text ) where number is your number field and text is your text field or the text to be 'multiplied'.
August 20, 200421 yr Author thanks! works great up to a number of 9, then I get "1.ae+9" - any suggestions?
August 20, 200421 yr Author yeah it is (Sorry to be asking you all this, but this is kind of over my head how you've done this)
August 20, 200421 yr Hmm. Well that sucks! The only alternative I know of would be to use a Custom Function. But you would have to have Developer to implement that.
August 20, 200421 yr Author sure does! - don't understand why it works from 1 - 8 but falls over at 9! I have developer 6... would that cover the other possibility?
August 20, 200421 yr At 10 ^ 9, version 7 auto-converts the number to scientific notation. Version 5.5 doesn't do that. Developer 6 wouldn't help because it doesn't have Custom Functions, nor is it compatible with version 7.
August 20, 200421 yr But it worked in Version 6 as you wrote it. Sample attached. MultiplyText.fp5.zip
August 20, 200421 yr I know. That's the frustrating part. Ray gave me the calc. I wonder if he has another option up his sleeve without using a Custom Function.
August 20, 200421 yr How about starting with a global text field that is just a lot of 0's. Lets call it gText. Now use it by modifing Queue's formula to: Substitute( Right( gText; number ); "0"; text )
August 20, 200421 yr Hi JT. I don't understand. Maybe it's the time of day, the number of hours that I have been sitting at this ******* machine, I'm having another Senior Moment, or what, but I guess I'm not understanding the problem. The File I attached earlier, although I made in v6, it also works in v5,03 too. Could this be one of the Bugs that 5.5 had? Or, what am I missing here. Lee
August 20, 200421 yr It works fine up until version 7. 7 automatically converts 10 ^ 9 into the scientific notation 1.0e+9, and there appears to be no way to GetAsText to make it 1000000000. So the formula returns 1.ae+9, if the text is "a". It's a really nasty change in 7.
August 20, 200421 yr Author Seconded! I'm revamping a long standing project. Decided to take advantage of some pretty significant developements that FM7 offers. I've been able to simplify LOADS, impressed till now. I thought I had seen the last of creating hidden fields containing lots of values in some kind of wierd "Heath Robinson" style ... guess not Thanks for your comments folks,
August 23, 200421 yr Nice to see you back, DJ! Thanks for the calc. But would you agree it's a bit overboard compared to what was necessary in version 6?
August 23, 200421 yr I was only kidding, the true formula is Substitute ( (10 ^ num)-1 ; "9" ; textToRep ) If necessary it could be extended for values for "num" greater than 404 Dj
August 23, 200421 yr I wonder why it doesn't convert that into 9.99e+(num - 1) or something similar. If you manually enter 10 nines in succession, it auto-converts them to 1e+10. Also, if you create another calculation of the number + 1, it displays trailing zeroes until you click in the field, then it displays scientific notation until you go to another record and come back or select a different program and then return to it. Very weird.
August 23, 200421 yr It didn't have time to do the conversion. If you split the calc, ie create test=(10^num)-1 and than substitute(test; "9";"aaa") it won't work Dj
August 24, 200421 yr The default field format for number (General Format) is doing some of this, if you select "Leave data formatted as entered" you'll see what's actually being stored in the database.
August 24, 200421 yr You're right. It was formatted as decimal. I'm still annoyed with this bug though.
August 25, 200421 yr A script can do this easily, if not quickly. {some initialization here} Loop InsertCalculatedResult[holder;Source] SetField[counter; counter=1] Exit Loop if [counter >= Multiplier] SetField[Product; holder] Product = Source&Source&...Source (Multipler times). Repeating "ask" 2000 times takes ~3 s. 5000 times ~ 9 s. Repeating an approximately 80 character Source 2000 times took 22 s. 450 MHz G4, OS X10.3.4 Lynn
August 27, 200421 yr Hi Substitute ( (10 ^ num)-1 ; "9"; Substitute ( (10 ^ num)-1 ; "9" ; textToRep ) ) Setting num to 404 and textToRep to "ask" took only 2 seconds in same configuration as your. BTW it's 163216 times repeated word "ask"
September 26, 200421 yr I tried this: Substitute ( Right ( SetPrecision(1/3;num) ; num) ; "3" ; textToReplace ) It works on the same idea but using divide instead of power. Sadly it only works up to 400 after which the decimal point is not correctly removed. The following, less pretty solution works up to 400. Let ( a = SetPrecision ( 1/3 ; num ) ; Substitute ( Right ( a ; Length ( a ) - 1 ) ; "3" ; textToReplace ) )
September 26, 200421 yr Now for the corker... Let ( [ hi = Div ( num ; 400) ; lo = Mod ( num ; 400) ] ; Substitute ( Substitute ( Right ( SetPrecision ( 1/3 ; hi ) ; If ( hi > 400 ; 400 ; hi ) ) ; "3" ; Right ( SetPrecision ( 1/3 ; 400 ) ; 400 ) ) & Right ( SetPrecision( 1/3 ; lo ) ; lo ) ;"3" ; text ) ) Works up to num = 160000 after which the result remains simply of length 160000. It's quick at approx. 1/4 second for num=160000. Thanks for the challenge...I'm going to use this in my graphing app! What do you think? [email protected]
October 2, 200421 yr Sorry to come in late but what does your corker do? I see some of the earlier text rep stuff which seems way easier but I don't quite see how you intend to use this or how it is related to graphing.
October 3, 200421 yr Agreed. And aven with 6, this technique would break at num = 214 due to the 64K floating limit. So you had to workaround this Ray's workaround So now we have Dj's calc for 7...and I was pleased to see him back here as well
Create an account or sign in to comment