Page 1 of 1
inserting text files in string
Posted: Tue Jan 22, 2019 7:24 am
by F_Laroche
Hi,
I used a code to save some string lists as text files, and now I'm trying to convert those text files as new string lists in another code. The only way I found is to create a blank string list and manually use the option "insert text file" as seen on the capture I also posted. When I check on the capture window, it doesn't seem to have registered a command. is such command exist?
thanks in advance
Re: inserting text files in string
Posted: Tue Jan 22, 2019 8:45 am
by EViews Gareth
You'd have to go through a text object. text.append to open the text file.
Re: inserting text files in string
Posted: Tue Jan 22, 2019 8:58 am
by F_Laroche
This create a new text object, but I need to convert those to string lists. Is it possible?
Re: inserting text files in string
Posted: Tue Jan 22, 2019 9:08 am
by EViews Gareth
What's a string list?
Re: inserting text files in string
Posted: Tue Jan 22, 2019 9:12 am
by F_Laroche
It's just a string object. Sorry about that.
Re: inserting text files in string
Posted: Tue Jan 22, 2019 9:28 am
by EViews Gareth
There isn't an easy way to do it. String objects aren't really intended for that sort of thing (I'm kinda surprised the menu item exists!).
If the text file only has one line, you would go through a text object, then grab the first line into a string. Or convert the text object into an svector and loop through or something.
Re: inserting text files in string
Posted: Tue Jan 22, 2019 9:31 am
by F_Laroche
Ok I understand. Since I saved those files from string objects that I created, is there a better way to save them for other use than saving them as text?
Re: inserting text files in string
Posted: Tue Jan 22, 2019 9:39 am
by EViews Gareth
No.
Given that there isn't a proc to save strings as text, how did you save them?
Re: inserting text files in string
Posted: Tue Jan 22, 2019 10:53 am
by F_Laroche
I used this code:
%BD = "EMERGE G10 EMERGECW EMERGELA EMERGEMA EMERGEPR"
for %B {%BD}
%path = "\\lacaisse.com\gdd\ACD\PR\HAVER\DATA\"+%B+".dat"
string list_{%B} = @wquery(%PATH, "name matches *", "name")
string list_{%B}_M = @wquery(%path, "freq=m", "name")
string list_{%B}_Q = @wquery(%path, "freq=q", "name")
string list_{%B}_A = @wquery(%path, "freq=a", "name")
FREEZE(flist_{%B}) list_{%B}
FREEZE(flist_{%B}_M) list_{%B}_M
FREEZE(flist_{%B}_Q) list_{%B}_Q
FREEZE(flist_{%B}_A) list_{%B}_A
%page = "M Q A"
%save = "h:\ra\gestion dynamique des devises\données\analyse comparative\emerging\donnees\tables\"+ %B + ".txt"
FLIST_{%B}.save {%SAVE}
for %p {%page}
%save_p = "h:\ra\gestion dynamique des devises\données\analyse comparative\emerging\donnees\tables\"+ %B + "_"+ %p +".txt"
flist_{%B}_{%P}.save {%save_p}
next
next
FREEZE(flist_{%B}_A) list_{%B}_A
FLIST_{%B}.save {%SAVE}
But I actually found a way to get around the problem, I juste saved the wf and opened it in my other program.
Thank you for your help.