DC Substitute Function

I’m getting around with DC now… unfortunately the descriptions of functions on help.sketchup.com is nothing like the API. I can nest IF() but no SUBSTITUTE( SUBSTITUTE(text, searchText, newText, occurrence), searchText, newText, occurrence).? So I had to add supporting attribute…

And why is a space " " not a sign in DC… SUBSTITUTE(“012 345 678”, " ", “”, 2) I tried this to remove spaces from my phone number but doesn’t wonna work.

Plus unlike the description of the function says “occurrence” is not optional…

=SUBSTITUTE(num,blank,"",2)

where blank

= " "

that is make an extra attribute for the special characters

1 Like

Thanks… I wouldn’t guess that one… I Actually did… I tested: =SUBSTITU(“1234 5678”," “,”“,2) It worked…
My problem turns out was caused by something else… Phone number was entered as user text edited attribute…
Box level Phone = 1234 5678 (units: Text)
Then I referenced in dipper level
=SUBSTITU(Box!Phone,” “,”",2)
it gives out:
1234 5678
I can not guess why it would even make a difference…

So I understand Nesting really isn’t possible…

Thanks once more @pcmoor … Ireally ment it even though reading now it looks not so polate… I wrote 2 first sentences when really thinking it works… and then eddited after finding that it didn’t …
=MID(“0123 0456”,1,4)
on my PC it gives back 123 Attribute is set to ‘text’ so I don’t understand why it is skipping the zero on the beginning…
=LEFT(“0123 0456”,4) as well returns 123
it really looks that it treats it like a number not text…
DC are messy…
edit
To be more funny :
=LEFT(“0123 0456”,1) gives me “0”
So I guess it is a default numeric value for nothing… or not… I did set it up to ‘text’. MID and LEFT work like that in single line… I didn’t reference it.

that is correct, the text is valued!
so use a text to preserve it

anum = “0123 0456”

=mid(" " & anum,1,5)

Yes there plenty of “bugs”, or should I say uncompleted code?
Is unlikely it will be fixed!
so work around, like…

position = find(“x”,“cat”,1)
creates an error, so as per above, use
position = find(“x”,“cat” & “x”,1) returns 4
then
found = if(position>len(“cat”),0,1)

these obvious “bugs” make DCs difficult, I only hope that “live components” are worth it, rather deciding not to revamp DCs, but that seems to be years away

1 Like

I tried this it shows as a result "012 - it shows quote mark and no 4th digit… And I want ‘anum’ to be typed in by user… I will have to require him to include quotation like: “phone_number”…?

to me
find(“x”,“cat” & “x”,1)
gives error too… maybe my PC causes mistakes…
value(“0123 4567”) gives: 123
but LEN(value(“0123 4567”)) gives: 5

Is there even one text function which works as it is suppose too?

I didn’t use lots of Live Components but to me it looked exactly like DC… The same functionality except LC are online and options window is fancier… Is it the same ‘engine’ or it is something totally new?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.