Knowledge Base
cancel
Showing results for 
Search instead for 
Did you mean: 

String comparison in TGML script is not working.

Issue

String comparison in TGML script is not working.

Environment

TGML graphics editor 1.1.X

Cause

Javascript has a string class and a string literal. String literals are denoted by double or single quotation marks ("" or '') and it is important to compare "like" with "like".

String literal: string1 = "Apples"

String class: string1 = target.getAttribute("Name");

Resolution

A deeper comparison is required in the example below. Instead of:

name = target.getAttribute("Name");
items = target.getParentNode().getElementsByTagName("Ellipse");

for(i=0;i {
tmp = items.item(i).getAttribute("Name");

if (tmp==name)

Use:

name = target.getAttribute("Name");
items = target.getParentNode().getElementsByTagName("Ellipse");

for(i=0;i {
tmp = items.item(i).getAttribute("Name");

if (tmp.equals(name))

An example is shown in the TGML graphic attached. Download graphic

 

Also check out the JavaScript Essentials - Episode 3 - Value Types Quick-Help video on the Exchange.

Tags (1)
Labels (1)
Version history
Revision #:
1 of 1
Last update:
a week ago
Updated by: