Home > Community > Forums > Custom IC SKILL > skill code to manipulate string fields inside a form

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: *

 skill code to manipulate string fields inside a form 

Last post Mon, Nov 19 2012 1:08 AM by Danilo P. 2 replies.
Started by Danilo P 16 Nov 2012 05:09 AM. Topic has 2 replies and 810 views
Page 1 of 1 (3 items)
Sort Posts:
  • Fri, Nov 16 2012 5:09 AM

    • Danilo P
    • Not Ranked
    • Joined on Mon, Nov 22 2010
    • Padova, Padova
    • Posts 15
    • Points 240
    skill code to manipulate string fields inside a form Reply

     Hello,

    Could someone suggest the reason why the following skill is wrong? Simply I need to clean field1, field2 and field3 in the form, but the "foreach"cycle in the clean() procedure doesn't do that. Only I am able to clean the field 3, with the command outside from the cycle.

    Is there any difference between the fist way and the second way? Of course this is just a very simplified example, my code is more complex and I need to delete fields whose names are member of a list.

    Thank you

    Danilo

    procedure(test()

    let(()

          fields = list(

                list( hiCreateStringField( ?name 'field1 ?prompt "Field1" ?value "10" ) 10:10 100:100 40)

                list( hiCreateStringField( ?name 'field2 ?prompt "Field2" ?value "20" ) 110:10 100:100 40)

                list( hiCreateStringField( ?name 'field3 ?prompt "Field3" ?value "30" ) 210:10 100:100 40)

                list( hiCreateButton(?name 'cleanButton ?buttonText "clean" ?callback "clean()") 10:100 50:50)

          )

          hiCreateAppForm(?name 'test_form ?formTitle "TEST FORM" ?initialSize t ?fields fields )

          hiDisplayForm('test_form)

    ))


    procedure(clean()

    let(()

          foreach(item list("field1" "field2")

                test_form~>item~>value = ""

          )

          test_form~>"field3"~>value = ""

    ))

     

     

    • Post Points: 20
  • Fri, Nov 16 2012 7:10 AM

    • ztzg
    • Not Ranked
    • Joined on Fri, Dec 31 2010
    • München, Bavaria
    • Posts 15
    • Points 225
    Re: skill code to manipulate string fields inside a form Reply
    Hi Danilo,

    > Could someone suggest the reason why the following skill is wrong?
    > Simply I need to clean field1, field2 and field3 in the form, but the
    > "foreach"cycle in the clean() procedure doesn't do that. Only I am
    > able to clean the field 3, with the command outside from the cycle.
    >
    > foreach(item list("field1" "field2")
    > test_form~>item~>value = ""
    > )

    The ~> infix operator maps to the getSGq macro, which quotes its second
    argument—so that it does not get evaluated as a variable. You could use
    the "naked" get function instead:

    let( (widget)
    foreach(item list("field1" "field2")
    widget = get(test_form concat(item))
    widget~>value = ""
    )
    )

    Cheers, -D

    --
    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
  • Mon, Nov 19 2012 1:08 AM

    • Danilo P
    • Not Ranked
    • Joined on Mon, Nov 22 2010
    • Padova, Padova
    • Posts 15
    • Points 240
    Re: skill code to manipulate string fields inside a form Reply

    Thank you very much.

    It works of course, but most important aspectfor me is that I learnt something I completely ignored before.

    Cheers, Danilo 

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by Danilo P at 16 Nov 2012 05:09 AM. Topic has 2 replies.