Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

A simple question that's gotten me foxed


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

Recommended Posts

Posted

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

Posted

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'.

Posted

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.

Posted

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?

Posted

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.

Posted

I know. That's the frustrating part. crazy.gifdoah.gif

Ray gave me the calc. I wonder if he has another option up his sleeve without using a Custom Function. Ask.gif

Posted

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 )

Posted

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 hairout.gif

Posted

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.

Posted

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 frown.gif

Thanks for your comments folks,

Posted

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?

Posted

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

Posted

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.

Posted

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

Posted

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.

Posted

You're right. It was formatted as decimal. I'm still annoyed with this bug though.

Posted

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

Posted

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"

  • 5 weeks later...
Posted

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 )

)

Posted

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]

Posted

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.

This topic is 7355 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.