UI Dialog Question
Posted: Tue Nov 22, 2022 11:05 am
I have some code that uses a for / next loop that takes a list of stock tickers and fetches some data from Bloomberg (MY CURRENT CODE shown below). It works well, but it would be much better if I did not have to open the program and change out the tickers in the body of the code each time the list of stocks changes. It would be very much better to put up a UI box and allow the user to enter in a list of tickers (IBM PG CAT).
My first attempt was to modify some of Gareth's code from the forum (below) and try to substitute %i after "for" in my current code. %i would be the variable that would hold the list of tickers supplied by the user. I assumed the resulting code would insert the user supplied tickers in place of "IBM PG CAT" and run the for next loop as it would when I enter the tickers directly into the code after %i. But this did not happen. Instead, I got an error "Syntax error in control statement in "FOR """ on line XX."
Could someone help me figure out what I've done wrong?
Many thanks!
MY CURRENT CODE:
for %i IBM PG CAT etc...
%name = %i + " US Equity"
fetch(link) bloom::%name 'Historic Price
stocks_price_gp.add {%i}_US
frml {%i}_rtn = ({%i}_US/{%i}_US(-1) - 1) * 100
stocks_rtn_gp.add {%i}_rtn
frml {%i}_excess = {%i}_rtn - tbill_rtn
if @obs({%i}_excess) > 0 then
stocks_excess_gp.add {%i}_excess
endif
next
GARETH'S CODE (Modified by me):
%i = "" 'variable to store list of stocks
!result = 0 ' variable that will track the result of dialogs. -1 indicates user hit Cancel. 0 Indicates user hit OK.
!result = @uiedit(%regs,"Enter the list of stocks") ' put up an Edit dialog asking for regressors list.
if !result=-1 then 'if user cancelled, then stop program
stop
endif
My first attempt was to modify some of Gareth's code from the forum (below) and try to substitute %i after "for" in my current code. %i would be the variable that would hold the list of tickers supplied by the user. I assumed the resulting code would insert the user supplied tickers in place of "IBM PG CAT" and run the for next loop as it would when I enter the tickers directly into the code after %i. But this did not happen. Instead, I got an error "Syntax error in control statement in "FOR """ on line XX."
Could someone help me figure out what I've done wrong?
Many thanks!
MY CURRENT CODE:
for %i IBM PG CAT etc...
%name = %i + " US Equity"
fetch(link) bloom::%name 'Historic Price
stocks_price_gp.add {%i}_US
frml {%i}_rtn = ({%i}_US/{%i}_US(-1) - 1) * 100
stocks_rtn_gp.add {%i}_rtn
frml {%i}_excess = {%i}_rtn - tbill_rtn
if @obs({%i}_excess) > 0 then
stocks_excess_gp.add {%i}_excess
endif
next
GARETH'S CODE (Modified by me):
%i = "" 'variable to store list of stocks
!result = 0 ' variable that will track the result of dialogs. -1 indicates user hit Cancel. 0 Indicates user hit OK.
!result = @uiedit(%regs,"Enter the list of stocks") ' put up an Edit dialog asking for regressors list.
if !result=-1 then 'if user cancelled, then stop program
stop
endif