Home > Community > Forums > PCB SKILL > PB in foreach

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 PB in foreach 

Last post Wed, Jan 23 2013 8:12 AM by Yann00. 4 replies.
Started by Yann00 23 Jan 2013 04:12 AM. Topic has 4 replies and 951 views
Page 1 of 1 (5 items)
Sort Posts:
  • Wed, Jan 23 2013 4:12 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    PB in foreach Reply

    Hi guys,

    I wanna do a foreach to read all my film names and I wanna print something if we are in the case "C02" or "SMB".

    I tried that:

    my_films_members = axlGetParam("artwork")->groupMembers

    foreach(film my_films_members->groupMembers
    filmparams = axlGetParam(strcat("artwork:" film))

      (case film
    ("C02" printf ("tout est ok"))
    ("SMB" printf("ok")))))

    But it doesn't work.

    Could someone have an idea please? I have only 2 days to close that.

     

    • Post Points: 35
  • Wed, Jan 23 2013 4:24 AM

    • ztzg
    • Not Ranked
    • Joined on Fri, Dec 31 2010
    • München, Bavaria
    • Posts 15
    • Points 225
    Re: PB in foreach Reply
    Hi Yann00,

    Not sure what you're trying to achieve exactly, but the first `printf`
    might be the culprit. In SKILL/SKILL++,

    printf("foo")

    is interpreted as:

    (printf "foo")

    whereas (notice the extra space):

    printf ("foo")

    is interpreted as, well, an error. (Technically, a reference to the
    `printf` variable, and an attempt at calling a string.)

    Hope this helps,
    Damien

    --
    http://crosstwine.com
    tel: +49 89 2189 2939
    cell: +49 174 3489 428

    “Strong Opinions, Weakly Held”
    — Bob Johansen
    http://www.crosstwine.com tel: +49 89 2189 2939 cell: +49 174 3489 428
    • Post Points: 20
  • Wed, Jan 23 2013 5:07 AM

    • D912349
    • Top 150 Contributor
    • Joined on Sat, Nov 24 2012
    • Posts 47
    • Points 800
    Re: PB in foreach Reply

    Try removing ->groupMembers  at foreach line.

    try this, this is exactly same as your program, only removed the ->groupMembers part

    my_films_members = axlGetParam("artwork")->groupMembers 

    foreach(film my_films_members->groupMembers 
    filmparams = axlGetParam(strcat("artwork:" film))

      (case film
    ("C02" printf ("tout est ok"))

    ("SMB" printf("ok"))))) 

     

    Hope it helps. 

    • Post Points: 5
  • Wed, Jan 23 2013 5:09 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 296
    • Points 4,710
    Re: PB in foreach Reply

    Change your code to the following since you taking groupMembers twice, once in axlGetParam and again in foreach exprList argument.

    fm = axlGetParam("artwork")->groupMembers

    foreach(film fm
       fp = axlGetParam(strcat("artwork:" film))

       (case film
       ( "C02"   printf("C02 Hi\n"))
       ( "SMB" printf("SMB Hi\n"))
       )
    )

     

    • Post Points: 20
  • Wed, Jan 23 2013 8:12 AM

    • Yann00
    • Top 200 Contributor
    • Joined on Tue, Dec 4 2012
    • Posts 42
    • Points 585
    Re: PB in foreach Reply

    That's brillant, it works exactly like I want.

    Really thanks to you fxffxf,  D912349,  ztzg.

    My printf was wrong, and my groupMembers too!

     

    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by Yann00 at 23 Jan 2013 04:12 AM. Topic has 4 replies.