Author Topic: If-Or-Statement within Shape Scripts  (Read 15673 times)

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
If-Or-Statement within Shape Scripts
« on: March 14, 2017, 09:44:57 pm »
Hi together,

is there a way to use an If-Or-Statement within a shape script?

"if-else" is not an option, because then I would have to copy the script within the brackets (e.g. if (a=1) {do XY} else if (a=2) {do XY}). I need something like "if (a=1) else if (a=2) {do XY}".

Setting a variable inside the shape script could help me, but I think that this is not possible (e.g. if (a=1) {var1=1}; if (a=2) {var1=1};  if (var1=1) {do XY}).

Any suggestions? Many thanks in advance V.
« Last Edit: March 16, 2017, 05:53:11 pm by Viking »

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #1 on: March 14, 2017, 10:51:57 pm »
Shapescript is dumb as bread. IF only accepts one HasProperty method as argument. No string comparison. No arithmetics.

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #2 on: March 15, 2017, 12:09:20 am »
Shapescript is dumb as bread. IF only accepts one HasProperty method as argument. No string comparison. No arithmetics. q.
Really? I thought that the existing scripting languages were not good enough and it was necessary to invent a new one. Is that a misinformation?

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #3 on: March 15, 2017, 01:59:45 am »
Why take a proven, existing language, if you can invent a new one? Or even another one for transformations?

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #4 on: March 15, 2017, 03:28:17 am »
Why take a proven, existing language, if you can invent a new one? Or even another one for transformations?
q.

This is a very good question. I don't know if we will find out the reason one day.

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #5 on: March 15, 2017, 12:50:03 pm »
Why take a proven, existing language, if you can invent a new one? Or even another one for transformations?

Suggest that it's replaced with SVG, that's always fun :-)

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #6 on: March 15, 2017, 09:08:09 pm »
Only if they consider including animated icons.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13136
  • Karma: +547/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: If-Or-Statement within Shape Scripts
« Reply #7 on: March 15, 2017, 11:22:35 pm »
Why take a proven, existing language, if you can invent a new one? Or even another one for transformations?

q.
The benefit is that it provides us (the consultants who know how to use those languages) with job security ;D

Geert

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #8 on: March 16, 2017, 01:09:30 am »
O.k. Back to the question. It seems to me that I have to copy the scrpt several times ->  if (a=1) {do XY} else if (a=2) {do XY}.

Or is there a possibility to implement subroutines (Like the sub shapes)?

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #9 on: March 16, 2017, 01:29:18 am »
The first sentence in my first reply still stands.

q.

Viking

  • EA User
  • **
  • Posts: 400
  • Karma: +2/-2
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #10 on: March 16, 2017, 04:36:53 am »
The first sentence in my first reply still stands.
q.

So there is no workaround. Many thanks for your answers.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8038
  • Karma: +118/-20
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #11 on: March 16, 2017, 08:47:04 am »
Yes, the language is simplistic.

I've handled this is the past by reversing the logic.

if (a!=1) {
   if (a!=2)   {do XY}
}

WarrenKenyon

  • EA Novice
  • *
  • Posts: 13
  • Karma: +1/-1
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #12 on: March 16, 2017, 09:36:39 am »
I believe what qwerty is saying is that you cannot do text or value comparisons in ShapeScript.  There is no "if ( a=1 )" syntax.  There is only "if (hasproperty(a))"

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #13 on: March 16, 2017, 10:44:10 am »
Exactly. The polite way of stating ShapeScript's capabilities is what Simon said. I'm more that rude guy.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8568
  • Karma: +254/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: If-Or-Statement within Shape Scripts
« Reply #14 on: March 16, 2017, 10:58:00 am »
Exactly. The polite way of stating ShapeScript's capabilities is what Simon said. I'm more that rude guy.

q.
So long as Simon meant "too simple to work properly" - which is the corect meaning of "simplistic".  Simplistic is NOT a fancy way of saying "simple". There's a word for that - "simple"

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!