What does esc(0) mean?

Started by analogman, February 26, 2020, 03:37:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

analogman

Greetings,

New user, first post.

I'm working with an existing custom shapes stencil and have come across a text field for a shape whose Format has the entry "esc(0)" (without the quotes). The text field entry of esc(0) is highlighted in blue and if I double click it, it shows =FIELDPICTURE(0). I can't find any documentation on what esc(0) means. The following Microsoft link mentions it but has no clear description of what it means.

https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa212682(v%3Doffice.11)

I appreciate any help anyone can provide.

Thanks,
analogman

Nikolay

As of my understanding, "esc(0)" means "default format", it's sort of internal notation.

You can try experimenting by changing the field format. For example, "esc(1)" would mean "data with measurement units", "@" would mean "text", "@+" would mean "uppercase text", etc
I'm not sure who came up with this cryptic notation, but why do you care, to start with?

Users are not supposed to edit this stuff through the ShapeSheet, there is a "noble" way:

analogman

Why do I care? I've been working on updating/adding shapes to an existing stencil and I stumbled across this esc(0) in an existing shape. I wasn't sure if a developer put it in there or if Visio put it in there and I'm trying to understand what is going on behind the scenes. (This is the first time I've had to modify a stencil.)

You pointed me in the right direction. I did some experimentation and discovered that Visio adds esc(0) in the Text Fields of the Shape Sheet when a field is inserted into the shape. Now I understand where it comes from and agree that I don't need to care.

Also, thanks for mentioning that there is a more "noble" way. I figured out the "noble" way but I have another question that maybe you can answer. I added a field inside a shape and used a custom formula that displays some information formatted as a string. For the sake of argument, lets say the custom formula is =Prop.somePropertyName.Label&": Some text". I entered this formula when the field was added but I see no way to modify it other than using the shape sheet. Is there another way?

Nikolay

#3
Hmm. Maybe you mean, how do you insert more than one field for example, split with a text fragment for example?

Usually this is the question, as it's a done in a bit confusing way. You start editing the text, and then insert fields (one or more). Please check the gif below.
The common "pitfall" here is to click "insert field" when just the shape is selected, and you have not switched to the the "text edit" mode first (there is a button, "edit text", or F2 shortcut).
In this case all text will be replaced and you won't be able to use multiple fields or text formatting.

To edit a field, you switch to text editing, then position the cursor below the target field, and click "Insert Field", it will open editor for the field.

The custom formula option may be useful when you need to put something really fancy to the field, not just format or use shape data this way or another..
Like, multiply PropertyA by PropertyB and then take a logarithm out of that :D

wapperdude

Some time back did post on shape vs field text.  The context was using VBA, but Reply #4, has Visio file that shows differences in a little more detail.  http://visguy.com/vgforum/index.php?topic=5678.msg22615#msg22615

If you switch to view formula in the shapesheet, you can edit the value in the format cell.  Or, remain in showing values, click on the format cell, and in the Visio header, upper left of the window, e.g., =FIELDPICTURE(0) to say, =FIELDPICTURE(2).  This cell changes, duh, the format of the displayed text.  Play with the entries.
Visio 2019 Pro

analogman

Nikolay, I don't recall seeing your image yesterday. Did you add it afterwards?

The question can be asked more clearly using your image. How can I get the Field window to open up on an existing field? This would be Window #2 in the image.

For example, yesterday I entered a custom formula for a newly added field using the Field window and today I realized that it wasn't quite right. I know I can edit the formula in the Shape Sheet as wrapperdude mentioned but is there someway to get the Field window back on an existing field?

BTW: Thanks for posting the GIF. It confirms that I was doing things correctly in a few experiments I performed.


Wrapperdude, I peeked at your other post briefly and it looks like it has some rather useful information that I can learn from. Thanks for posting the link. I'll see if I can find time later today or next week to do some experiments.

Nikolay

I don't quite understand the issue. Step by step maybe:

- select your shape.
- click F2 to start text editing.
- select the field you want to edit (click it)
- click "insert field", it will open the editor for the selected field

analogman

As a prerequisite to your steps, assume that the shape has a property named Status which was added using the Define Shape Data window.

Then, add two more steps to what you provided:
- select your shape.
- click F2 to start text editing.
- select the field you want to edit (click it)
- click "insert field", it will open the editor for the selected field- Select "Custom Formula" in the Field window

- enter the following text in the Custom formula text box ="Status: "&Prop.Status
- click OK

Now, let's say that at this point I want to change the custom formula
  From: ="Status: "&Prop.Status
  To:     ="CPU Status: "&Prop.Status

How do I go about opening up the editor window on this field so that I can edit the custom formula?  (This would be the editor window shown as #2 shown in your image)

Nikolay

#8
I think there is a confusion. You don't need to enter any custom formulas, especially in ShapeSheet, with these cryptic "&" symbols. It's much easier!

You do it like this:

- select your shape.
- click F2 to start text editing.
- type "Status: "
- click "insert field", it will open the editor to select the field, select "shape data" (item in the right list), "Status" (item in the left list)
- type line break (click Shift+Enter)
- type "CPU Status: "
- click "insert field", it will open the editor, select "Shape Data", "CPU Status"

That's it :)

To clarify: shape text can contain any number of fields. It looks actually like this:

The brown <animal_one> jumped over the lazy <animal_two>

Here "animal_one" is a field and "animal_two" is a field. The shape text flows as above, i.e. in some places of the text you may have insertions (fields) that are coming from elsewhere (like shape data). But there is no need to put all the text in a single giant formula and then try to fix it; it's not how it was thought to work.

analogman

I fully understand. Perhaps the confusion is due to that fact that I have not been giving you the full story.

I'm doing more in the custom formula like displaying different text based on values in the shape data properties. I tried to provided a simple example just to get to the point of my question which is how to reopen the window. Looks like there is no way and so I'll just continue to use the Shape Sheet method.

Many thanks for your help.


Yacine

You can populate the text by code - including dynamic fields.
Yacine