Add backslash '\' character between two string?

Hey folks, I hope I’m missing something simple here - I’m developing a table where I’m managing files stored on my various NAS and computer system(s).

I’m simply trying to concatenate strings like a drive letter “D:”, a folder “Documents” and finally a Filename “Testfile.txt”

In my table, I have a formula column [Pathname] where I attempt bring all of these fragments together e.g.:
“D:” + “\” + “Documents” + “\” + “Testfile.txt”

And I get errors in the formula due to the backslash?
(…And I’m noticing here creating this post, singular backslashes disappear and I have to double them up just so this message reads correctly!)

I tried escaping the backslash in my formulas using double backslashes “\\”, singular characters: ‘\’ etc., with no joy?

Am I missing something simple?

My NAS drive would be “\\MultimediaNAS\…” with two leading backslashes but all the formulas I attempt to put together just to get my various file path elements merged together all lead to errors within the concatenations.

Any help appreciate on how to accomplish this is appreciated! (Is there a Chr() or other text function I’m missing perhaps??)

Thanks!

Hi @William_Bell :blush: !

Maybe you could use Format() ? :innocent:

As apparently, the backslash (\) seems to be indeed a bit problematic :thinking:
But it does seem to work within Format()

See the formula in quick sample below which looks like this :

Format(
  "{1}:\{2}\{3}",
  thisRow.Drive,
  thisRow.Folder,
  thisRow.File
)

Add-on: Apparently you can also obtain a backslash (\) using the Character() formula :innocent:.
And the Backslash (Reverse solidus) corresponding CharNumber is 92 :blush: :

  • Character(92)\ .

So I’ve just updated the sample and added 2 other formulas :innocent:
One using some ListCombine() & Join()

ListCombine(
  Concatenate(thisRow.Drive,":"),
  thisRow.Folder,
  thisRow.File
).Join(Character(92))

And a simple Concatenate():

Concatenate(
  thisRow.Drive,":",
  Character(92),
  thisRow.Folder,
  Character(92),
  thisRow.File
)

Sorry for the lack of explanations but I hope this will help you a little :innocent:

1 Like

There is definitely a bug as the Length("\\") function should return 1.

1 Like

In code \ ignores quotes in your case.
“Exhaust sequence”. Is also used for regex

the backslash in your case causes the quotes to be ignored. As in the example below

image

2 Likes

Thanks helping me with this!

I believe I saw Format mentioned in other help threads when I first started browsing Coda’s forums, but forgot about it, having never used it.

Character is also another good one - I had def looked for Chr (I’ve used that in other languages). :stuck_out_tongue:

Thanks again, everyone - much appreciated!

2 Likes

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