Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.ini limitation...
#1
Well, I think I just stumbled across one of those limitations G. spoke of when using .ini files to do a rset/rget!

Heres and example for how the .ini file would look:
[Payments]
7/28/2008 12:49:31 PM=Data1|Data2|Data3|Data4|Data5|
7/28/2008 12:50:31 PM=Data1|Data2|Data3|Data4|Data5|
7/28/2008 12:51:31 PM=Data1|Data2|Data3|Data4|Data5|

Now how do I grab the variable with rget when I can't be sure exactly what it is? I was really hoping it would be simple like using:
rget Data * "Payments" FileName
But it's not.

Well...back to more coffee and programming. Thanks in advance for any help with this!
Jimmy Vig
#2
using xml it could be

Macro
Code:
Copy      Help
;this macro shows how to write XML file that looks like

;<payments>
;<i>
;,<date>7/28/2008 12:49:31 PM</date>
;,<x>Data1|Data2|Data3|Data4|Data5|</x>
;,<!-- and here you can add more tags, for example use different tags for Data1, Data2, etc -->
;,<!-- unlike in HTML, tag names are not predefined. You define them. But use only alphanumeric characters, _ and -. -->
;</i>
;<i>
;,<date>7/28/2008 12:50:31 PM</date>
;,<x>Data1|Data2|Data3|Data4|Data5|</x>
;</i>
;<i>
;,<date>7/28/2008 12:51:31 PM</date>
;,<x>Data1|Data2|Data3|Data4|Data5|</x>
;</i>
;</payments>


str xmlfile="$desktop$\pa.xml"
if(!dir(xmlfile)) _s="<payments />"; _s.setfile(xmlfile)

IXml xml=CreateXml
xml.FromFile(xmlfile) ;;load existing file, because this macro is going to append, not replace
IXmlNode re=xml.RootElement ;;payments
IXmlNode ni

ni=re.Add("i")
ni.Add("date" "7/28/2008 12:49:31 PM")
ni.Add("x" "Data1|Data2|Data3|Data4|Data5|")

ni=re.Add("i")
ni.Add("date" "7/28/2008 12:50:31 PM")
ni.Add("x" "Data1|Data2|Data3|Data4|Data5|")

ni=re.Add("i")
ni.Add("date" "7/28/2008 12:51:31 PM")
ni.Add("x" "Data1|Data2|Data3|Data4|Data5|")

xml.ToFile(xmlfile)
;note: you can save (call ToFile) multiple times, not necessary only at the end
;note: QM 2.3.0.2 also will have an autosave option, plus some more

Macro
Code:
Copy      Help
;this macro shows how to get data from the XML file

str xmlfile="$desktop$\pa.xml"
if(!dir(xmlfile)) ret

IXml xml=CreateXml
xml.FromFile(xmlfile)
ARRAY(IXmlNode) a
xml.Path("payments/i" a) ;;populates array a with all i tags
int i
for i 0 a.len
,IXmlNode& n=a[i]
,str s1=n.ChildValue("date")
,str s2=n.ChildValue("x")
,out s1
,out s2
,out "------"
#3
Holy cow! I am going to have so much fun with that! I feel like the whole world has opened up to me! Well...until I need to do something new!
So much better than .ini files! So Much Better!

Thank you so much for your help as always!


Forum Jump:


Users browsing this thread: 1 Guest(s)