Book a Demo

Author Topic: HasTag with Memo  (Read 3743 times)

bacz

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
HasTag with Memo
« on: July 01, 2018, 07:51:06 am »
Hi my fantastic team of Spark experts,
I am doing a shape script where I have a <memo> field called "PainPoints"

I want to print a red cross on the element if ANY text is in this field, otherwise just ignore it.

I have done this in a connector successfully i.e.
if (HasTag("PainPoints","")) {}
   else {
     setfixedregion(40,-10,60,10);
   
     setFillcolor(255,0,0);
     rectangle(40,-10,60,10);
     moveto(40,-10);
     lineto(60,10);
     moveto(60,-10);
     lineto(40,10);
    
   }
It works perfectly if something in, and does affect output if empty.
HOWEVER, when I come to do exactly the same feature for a component element, it doesn't seem to work and prints the else condition everytime.
Do you know if that is a bug, or do I have to do something different for a component? Code below. The issue is I get a cross whether I put something in the memo field PainPoints or not.


   if (HasTag("PainPoints",""))
        {}
     else {
      

          
         setfillcolor(255,0,0);
         startpath();
         moveto(38,35);
         lineto(51,70);
         moveto(38,70);
         lineto(51,35);
         endpath();
         fillandstrokepath();
        }

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: HasTag with Memo
« Reply #1 on: July 01, 2018, 10:22:26 am »
Not aware of any bugs. Looking at the help files it says this about the HasTag function
Quote
HasTag(tagname,tagvalue) evaluates to 'True' if 'tagname' exists and its value is
'tagvalue'.

HasTag(tagname,tagvalue) will also evaluate to 'True' if 'tagname' doesn't exist and
'tagvalue' is empty, treating 'empty' and 'missing' as having the same meaning in
this context.

So assume you have the tagname on the component as its never evaluating to true. Also check a default value of something other than "" is not being added.

One thing which you may want to consider and investigate further is that tags have two places it puts information, one is a single line string and the other is multi-line string. When you use <memo> its that multi-lined space which is different. This is evident when you export tagged values into csv files. It can be tagged_value or tagged_notes. I can't see anything in the API that tests for notes so it might be you are testing against the single line string rather than the multi-line string.

Also if you are using eap or eapx try opening the DB in MS Access and inspecting the values in t_objectproperties table as that is where tagged values are stored.

Dunno if that helps ???

« Last Edit: July 01, 2018, 10:26:10 am by Sunshine »
Happy to help
:)

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: HasTag with Memo
« Reply #2 on: July 01, 2018, 11:29:50 am »
You can also try this in the else condition
PrintWrapped("#TAG:PainPoints#");


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: HasTag with Memo
« Reply #3 on: July 01, 2018, 05:09:44 pm »
It does not depend on the element type if you apply the same shape script in a stereotype. I could think that your components for some reason have just (a) blank(s) in the tag value. So it looks like they are empty, but actually they are not. If you want to also check any blanks to be handled the same way you need to implement that in an add-in which you can call in the shape script with hasproperty('addin:myAddIn', '1').

q.