1

Almost have this quandry figured out, but inevitably a new problem has popped up. I finally have the "code" part down to do what I want, but now the font formatting isn't acting properly. When I use a simple expression with font tags I can create this image. enter image description here

However, when I use the advanced expression as follows, it returns the garbled image after. I'm using the tags the same way and can't find any reason they shouldn't be working. Without quotes I get a syntax error. EDIT - Trimmed code to focus on issue area. Font tags were improperly placed, see answer 1.

if float([Percentage_Complete]) >= 90:
lab1 = "<bol><clr green='255'>" + lab1 + "</bol></clr>\n"
if float([Percentage_Complete1]) >= 90:
lab2 = "<bol><clr green='255'>" + lab2 + "</bol></clr>\n"
if float([Percentage_Complete2]) >= 90:
lab3 = "<bol><clr green='255'>"+ lab3 + "</bol></clr>\n"
if float([Percentage_Complete3]) >= 90:
lab4 = "<bol><clr green='255'>"+ lab4+ "</bol></clr>\n"

enter image description here

asked Jul 21, 2014 at 18:28
15
  • I found that it might need to use the & operator to concatenate, but I get a syntax error with that as well around the lab1, etc. Commented Jul 21, 2014 at 18:30
  • Try enclosing them in one more set of quotations Commented Jul 21, 2014 at 18:35
  • I get the logic, but gives me a syntax error. And that would have been ridiculous if that was necessary to make that work. Thanks for the thought though. Commented Jul 21, 2014 at 18:39
  • After your if statements they should also be indented Commented Jul 21, 2014 at 18:43
  • 2
    You have the bol and clr tags end tags in the wrong order. It should be <bol><clr green='255'>"+ lab4+ "</clr></bol>\n" for each of them. Commented Jul 21, 2014 at 19:32

3 Answers 3

3

This was determined to be the issue to this problem. It will be marked as the answer soon. When using format tags make sure they close from inside out. Thanks to @kenbuja for clarifying that.

"<bol><clr green='255'>"+lab4+"</clr></bol>"
NOT "<bol><clr green='255'>"+lab4+"</bol></clr>"
answered Jul 21, 2014 at 19:58
2
  • Would you be able to edit your answer to state clearly that it does answer your question, please? Also, so others do not have to go through the same pain perhaps you can simplify your question to just the parts that in hindsight were causing all the problem so that a cleaner Q&A results? Commented Jul 21, 2014 at 21:06
  • Sure I can do that, I tried to mark it as the answer, but said I had to wait two days. But I'll clean it up. Commented Jul 22, 2014 at 12:00
1

This works to simply bold text and include a new line:

"<bol>" + [PointID] + "</bol>" + "\n" + [Structype] 

to get

6438
Manhole

answered Aug 25, 2017 at 19:34
1
  • This doesn't provide an answer to the question, how you set green color if the number is greater than 90? Commented Aug 25, 2017 at 19:45
0

Try using the ampersand as you suggested and use vbcrlf instead of \n. I don't think \n works

"" + [PARCEL] & vbcrlf & "TEXT" & "" something like this

answered Jul 21, 2014 at 18:39
7
  • If it matters, the error I get with the & indicates a problem between 'str' and 'unicode'. I assume the unicode is my variable name lab1, lab2, etc. Oh, and I thought I mentioned it, but guess not, this is for Python not VB Commented Jul 21, 2014 at 18:42
  • can you convert the unicode in the attributes ? Something like str(lab1) ? Commented Jul 21, 2014 at 18:49
  • Yes I suppose I wasn't thinking about the code you had there. I was thinking it was code you put in an expression. It wouldn't be easy to redo it if it were a script. Still I can run the str() python function on my attributes and it works. Commented Jul 21, 2014 at 18:56
  • Another good thought, but no go. Commented Jul 21, 2014 at 18:56
  • It is code I put directly into the advanced expression box in the label properties under the Python parser. Commented Jul 21, 2014 at 18:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.