File Window Tip - Making a space count as literal text

Started by Darius1968, October 24, 2021, 01:35:36 PM

Previous topic - Next topic

Darius1968

Assuming this statement, for a line, of my FW Tip: 
{File.MD.cameraname|prefix:<Run FontSize='14pt'>;postfix:</Run>}{File.MD.aperture|prefix:<Run FontSize='14pt'>F ;postfix:</Run>}

The prefix statement, of "File.MD.aperture", has "F".  Now, ", F" works, because there is a comma, that precedes the space character.  However, I don't want the comma; I just want the space character, itself.  But, " F", will not enumerate a space character.  So, how can I achieve that, if it's possible? 

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

Okay, I had a study of that. 
" ", for outputting one or more spaces works great, if I'm not working around the "prefix" or "postfix" statements of a variable.  However, when I'm trying to output more than one space, inside of a "postfix" statement, it doesn't work, and furthermore, in this situation, I have to use the space character, because " " fails.  So, what to do in this context? 

Mario

I don't understand.
As usual, it helps if you provide a minimum of information about what you are doing. Like, the variable you use.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

Okay.  Consider, the following statement: 

<Run FontSize="16pt">{File.MD.aperture|prefix:F ; postfix: at }</Run>

The "*#160;", I entered, for prefacing "at" with a space character, causes output to fail.  I can replace the postfix: statement, with " at ", which would successfully, give me the output " at ", but if I enter two or three space characters, I still only get the output, " at ".  So, how can I preface the "at" with three spaces, to yield, "   at "? 

Mario

The ; separates functions in variables.  Try to escape it with ~

Scratch that. & is a special XAML token and ; is used to separate variable functions.
Maybe something like pereplace? Alongside https://www.photools.com/3906/custom-icons-file-window/

Does also not work. postfix is special function which is always run as the last function. After replace and pereplace.

I have found a trick, I guess.
Create an Application Variable named XAMLSPACE, with the value   See Variables
Then use it in your expression like so:

<Run FontSize="16pt">{File.MD.aperture|prefix:F ; postfix:{Application.Variables.XAMLSPACE}at }</Run>

postfix runs after all escaping has been done, so the   is inserted as-is.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

At least we could work with some, hmmm, tricks.

Use some text (plain or variables) with the same forground color like the background, hence it is invincible.

<Run FontSize="16pt">{File.MD.cameraname|prefix:F }</Run>  <Run FontSize="16pt" Foreground="#3b3b3b" >{File.MD.aperture|substr:0,3}</Run>  <Run FontSize="16pt">{File.MD.aperture|prefix:at }</Run> next ...

Here we use 3 characters from aperture, and use the same color like the background.
I do not really know, what you are want exactly, therefore I cannot give real examples.

Of course, it this would be possible "native", it would be always the best.  :D ... but sometimes we have to use tricks.  ;D
Best wishes from Switzerland! :-)
Markus

Mario

The   entity is native to XAML.

The problem here is that this expression is used in an unsafe context and that variables by default escape unsafe characters when being used in a XAML context.
Furthermode, the postfix function is special, because it is executed as a postfix, after all other processing has been done. Hence, no replace or prereplace available.

I would just have added a second variable instead (one that produces an empty output), which produces the same effect as the postfix but can use pereplace to replace ABC with $#160; after the fact.
But with the global variable you can make this configurable in one place, allowing you to change this in all layouts with a single step.

Your idea with the invisible characters also works well.

There is usually a way to do things. It's just that I personally never use such complex things. I like to keep everything simple and slick.
Hence I may not always come up with a solution. Fact: Many IMatch users out there actually work a lot more with IMatch than I do. I spend most of my time developing IMatch  :)
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on October 27, 2021, 04:29:56 PM
...

There is usually a way to do things. It's just that I personally never use such complex things. I like to keep everything simple and slick.
Hence I may not always come up with a solution. Face: Many IMatch users out there actually work a lot more with IMatch than I do. I spend most of my time developing IMatch  :)

True, true. With IMatch we can really do a lot!! I am quite sure, some stuff, what we can do with IMatch, you could not do with other DAMs.
I work a lot with variables, inside Design & Print, and also others like custom windows layouts.

And indeed, variables are very powerful.
Users has different views, sometimes I like also the KISS-principle, but sometimes also the "very complicated"-stuff.  ;D

That you, Mario, spends most of your time with developing, well, that is our luck.  :)
Best wishes from Switzerland! :-)
Markus

Darius1968

Quote from: Mario on October 27, 2021, 01:44:00 PM
The ; separates functions in variables.  Try to escape it with ~

That worked on my end.