giles Posted August 20, 2004 Posted August 20, 2004 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
-Queue- Posted August 20, 2004 Posted August 20, 2004 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'.
giles Posted August 20, 2004 Author Posted August 20, 2004 thanks! works great up to a number of 9, then I get "1.ae+9" - any suggestions?
giles Posted August 20, 2004 Author Posted August 20, 2004 yeah it is (Sorry to be asking you all this, but this is kind of over my head how you've done this)
-Queue- Posted August 20, 2004 Posted August 20, 2004 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.
giles Posted August 20, 2004 Author Posted August 20, 2004 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?
-Queue- Posted August 20, 2004 Posted August 20, 2004 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.
Lee Smith Posted August 20, 2004 Posted August 20, 2004 But it worked in Version 6 as you wrote it. Sample attached. MultiplyText.fp5.zip
-Queue- Posted August 20, 2004 Posted August 20, 2004 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.
RalphL Posted August 20, 2004 Posted August 20, 2004 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 )
-Queue- Posted August 20, 2004 Posted August 20, 2004 That's a good workaround. But there shouldn't need to be a workaround.
Lee Smith Posted August 20, 2004 Posted August 20, 2004 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
-Queue- Posted August 20, 2004 Posted August 20, 2004 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.
giles Posted August 20, 2004 Author Posted August 20, 2004 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,
Lee Smith Posted August 21, 2004 Posted August 21, 2004 JT said: It works fine up until version 7. Say good night Lee.
djgogi Posted August 23, 2004 Posted August 23, 2004 Substitute (Floor ( Exp ( Ln ( 10 ^ num )) ) ; "9" ; "a" ) Dj
-Queue- Posted August 23, 2004 Posted August 23, 2004 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?
djgogi Posted August 23, 2004 Posted August 23, 2004 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
-Queue- Posted August 23, 2004 Posted August 23, 2004 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.
djgogi Posted August 23, 2004 Posted August 23, 2004 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
The Shadow Posted August 24, 2004 Posted August 24, 2004 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.
-Queue- Posted August 24, 2004 Posted August 24, 2004 You're right. It was formatted as decimal. I'm still annoyed with this bug though.
Lynn Johnson Posted August 25, 2004 Posted August 25, 2004 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
djgogi Posted August 27, 2004 Posted August 27, 2004 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"
Russell Watson Posted September 26, 2004 Posted September 26, 2004 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 ) )
Russell Watson Posted September 26, 2004 Posted September 26, 2004 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]
bruceR Posted October 2, 2004 Posted October 2, 2004 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.
Ugo DI LUCA Posted October 3, 2004 Posted October 3, 2004 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
Recommended Posts
This topic is 7712 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 accountSign in
Already have an account? Sign in here.
Sign In Now