Newbies Yancey Grantham Posted April 13, 2013 Newbies Posted April 13, 2013 I'm using the script provided at http://cookingwithplugins.com/recipe.htm?id=125 and it always returns a 1 at the beginning. Any ideas to get rid of this stray 1? SMSetVariable ( "symbol" ; MyTable::stock_symbol ) & EvaluateGroovy ( "String url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=l1"; return new URL(url).getText().trim();" )
Karsten Wolf Posted April 13, 2013 Posted April 13, 2013 That is an error in the recipe. It does what you tell it to do.  Return the (string) result of: SMSetVariable ( "symbol" ; MyTable::stock_symbol )   /* =1 for success I guess */ & /*<- remember this symbol? It concatenates strings */ EvaluateGroovy ( "...  What the author meant is most probably:  SMSetVariable ( "symbol" ; MyTable::stock_symbol ) AND EvaluateGroovy ( "...  which does not work either because it simply returns the "1" which means the ANDed result of both operations (with the desired result of the stock quote being discarded).  So we have to play it a bit safer here and ask explicitly for the success of the SMSetVariable call:   If (  SMSetVariable ( "symbol" ; MyTable::stock_symbol ) ;     EvaluateGroovy ( "String url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=l1"; return new URL(url).getText().trim();" );     "")   Or you could make it a ScripMaster module which would look like this:    Remember: ScripMaster returns text. If you live in a region of the world where "," instead of "." is used, you'll have to substitute that yourself. 1
john renfrew Posted April 13, 2013 Posted April 13, 2013 Or use the more Groovy form with singe apostrophe inside the function which makes it easier to read in FM If ( SMSetVariable ( "symbol" ; MyTable::stock_symbol ) ; EvaluateGroovy ( "url = 'http://download.finance.yahoo.com/d/quotes.csv?s=' + symbol + '&f=l1'; return new URL(url).getText().trim();" ); "")
Newbies Yancey Grantham Posted April 13, 2013 Author Newbies Posted April 13, 2013 Thank you Karsten and John, your suggestions worked and are appreciated.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now