[Swift-devel] file declaration inside foreach

Ben Clifford benc at hawaga.org.uk
Mon Apr 30 15:02:29 CDT 2007



On Wed, 25 Apr 2007, Mihael Hategan wrote:

> On Wed, 2007-04-25 at 10:04 -0500, Mihael Hategan wrote:
> > That with the assumption that k[i-1] would work.
> > It seems that k[i] = k[i-1] + i gets translated into this:
> > assign(dpath="[i]", dvar=k, 
> >   svar = sum(getFieldValue(var=k, path=concat("[]")), getFieldValue(i))
> > )
> > 
> > Seems like k[i-1] is translated into the wrong thing there
> > (path=concat("[]")).
> 
> It could, instead, be translated into: concat("[", subtraction(i, 1),
> "]"). My guess is that would work.

I tried this:

                      <vdl:assign dpath="[i]" dvar="{k}">
                        <argument name="svar">
                        <sum>
                          <vdl:getfieldvalue var="{k}">
                            <argument name="path">
                              <concat>
                                <string>[</string>
                                <subtraction><variable>i</variable>
                                             <number>1</number>
                                </subtraction>
                                <string>]</string>
                              </concat>
                            </argument>
                          </vdl:getfieldvalue>  
                          <vdl:getfieldvalue var="{i}"/>
                        </sum>
                        </argument>
                      </vdl:assign>

which I think is pretty much what you said in the non-xml syntax.

But I get this:

$ swift aaaa.kml 
Swift V 0.0405
RunID: 7e7ozhoot4ha0
Execution failed:
        org.globus.cog.karajan.workflow.KarajanRuntimeException: Could not 
convert value to number: 1

so then I tried this instead:

                  <parallelFor name="$">
                    <vdl:getarrayfieldvalue path="" var="{r}"/>
                      <set names="$$, i">
                        <each items="{$}"/>
                      </set>
                      <vdl:assign dpath="[i]" dvar="{k}">
                        <argument name="svar">
                        <sum>
                          <vdl:getfieldvalue var="{k}">
                            <argument name="path">
                              <concat>
                                <string>[</string>
                                
<subtraction><getfieldvalue><variable>i</variabl
e></getfieldvalue>
                                             <number>1</number>
                                </subtraction>
                                <string>]</string>
                              </concat>
                            </argument>
                          </vdl:getfieldvalue>  
                          <vdl:getfieldvalue var="{i}"/>
                        </sum>
                        </argument>
                      </vdl:assign>
                  </parallelFor>


(adding in a getfieldvalue)

and when I run that it sits in an infinite loop (second today lucky me!) 

Bleugh.

full kml (edited from what came out of the compiler) is 
http://www.ci.uchicago.edu/~benc/aaaa.kml

and the source I started with is in

http://www.ci.uchicago.edu/~benc/aaaa.swift

-- 




More information about the Swift-devel mailing list