another dxMemData question

Forum: ProgrammersTotal Replies: 11
Author Content
J_Maxwell

Oct 09, 2002
6:57 PM
Hello!

I am trying to load all the lines of text, separated by a delimmeter, and then send them to their different fields. I have it all down-pat, except for one thing. It seems to randomly choose which line it wants to load, and then it only loads that one line. Is there code that works (I can't post it, because the forum overrides it)?

Also, is there a cleaner way to save delimmited files from the dxMemData component than it's SaveToTextFile? Is that just me? It puts a whole bunch of delimmiters on different lines, confusing the LoadFromTextFile.

Thanks,

J_Maxwell
DaveKlein

Oct 09, 2002
10:24 PM
Hmmm. I've never had a problem with LoadFromTextFile loading a file created by SaveToTextFile unless you change the table structure in between saving and loading. I could see you having problems with other programs that use delimited files since the TdxMemData component uses it's own format. Perhaps you could email me the code that you are using.

As for other ways to save the data, here's an example that will create a comma delimited file:

{The forum seems to get rid of my indents but you should be able to get the idea.}
S := TStringList.Create;
i := 0;
with dxMemData1 do
begin
First;
while NOT EOF do
begin
str := '';
for i := 0 to Fields.Count -1 do
begin
if Fields[i] is TStringField then
str := '"' + Fields[i].AsString + '",'
else
str := Fields[i].AsString + ',';
end; //for
S.Add(str);
Next;
end; //while
S.SaveToFile('c:myDirmyFile.txt');
end; //with
J_Maxwell

Oct 10, 2002
7:45 PM
DaveKlein,

I got that all figured out, and it saves like a whiz. But I ran into another problem... again. This has a little different nature than the other problems. It only loads the first column, and leaves the other blank. Am I just being ignorant of the truth? Would a for loop work? To see the code I used, go to: [HYPERLINK@www.we-communicate.com] (the forum must be hungry tonight, I noticed that your code did not get eaten up ;-)!)

Thanks for the help,

J_Maxwell
DaveKlein

Oct 11, 2002
5:15 PM
It looks like you need a while loop. I was trying to post a sample but now the forum is eating my code too. Just put the code that is reading the value into the stringlist, including the Next call inside of a while NOT dxMemData1.EOF do loop. The way it is now it will only load the first row.

Hope that helps.
J_Maxwell

Oct 14, 2002
8:57 PM
It worked! Now I can load all of the lines of the file! But, if I do: the if indexof statement and then: str.add(dxMemData1.FieldByName('item').AsString);

end;//if

it loads the whole file into item, not just the column, item.

Any ideas?

J_Maxwell
DaveKlein

Oct 15, 2002
9:44 AM
I don't quite understand your problem. What do you mean by the whole file and what is "item". It seems that the word item is being used for two different things in your code. You have a field called item in your dxMemDataSet and item is a property of your component. So, I'm not sure which one you're referring to here. Could you post the current code or put it on a page and post the link? That would make it easier for me to see what's happening.

Thanks.
J_Maxwell

Oct 17, 2002
8:00 PM
Thank you for your reply. Sorry for not getting back soon enough. Here is the link: [HYPERLINK@www.we-communicate.com] . I am going to try to explain everything that I want it to do.

I have two fields, it will be four or five in the future, in data (TDXMemData). I basically want to load those two columns, separated by anything, into a TOvcDataReportView. I right now am loading it into a stringlist first and then dumping that into the ReportView.

It just won't load or put anything into the report view.

Any ideas on what I might be doing wrong?
DaveKlein

Oct 18, 2002
6:54 PM
You've stumped me on that one. It appears that the problem is with the TOvcDataReportView component. I haven't read up on it too much yet, but I think that there is more that needs to be done with it than just adding items. I will try to look at the Orpheus manual a bit later and see if I can figure it out. If you find anything first, please post it here.

One note about your code though, when you are checking to see if the item already exists in the StringList you might want to go ahead and add the quantity to the other StringList then to. The way it is now you might have a situation where the item is not in the first list but the quantity is already in the other list, but for a different product. Then you're lists will be out of sync. If you just add to both lists in the first if/then block it will always stay in sync.

Sorry I can't be more help this time.
DaveKlein

Oct 19, 2002
8:13 AM
I read up a bit on the TOVCDataReportView component and I think I found what might be missing. You need to do a few things to get data to show up in the TOVCDataReportView. I think you've done most of these steps but I'll list them all just in case: First create the fields that you want to display. Next create a view (from the Views property in the object inspector) and add fields to it that match the fields you created in the Fields property. Next set the ActiveView property to the view you just created. Then if you add an item and set the fields of that item they should show up.

Give that a try and let us know how it worked.
J_Maxwell

Oct 19, 2002
2:36 PM
Thanks for the reply. I checked throught what you said and I am doing everything as it is supposed to be. After your post last night, I re-wrote everything, and instead of using the stringlist to put the lines into the report view, I directly put the text into a memo, and found a problem. For it to properly load, I have to click the button that loads twice. It's almost like it has to initalize or something, but for every line of text, it displays a return. When I click the button the second time, it loads the text. And when I do the save procedure, I have to declare what's in the fields, I only have to click the button once.

Keeps getting more confusing,

Thanks for the help,

J_Maxwell
DaveKlein

Oct 19, 2002
3:25 PM
What you described with the Memo sounds like you might have a blank row in your dxMemData component. One way to see what's in there at any time is to stretch out your form a bit and drop a TDBGrid and a TDatasource on the form. The TDBGrid is on the Data Controls tab and the TDatasource is on the Data Access tab. Then set the DBGrid's Datasource property to the Datasource you just dropped on and set the DataSource's Dataset property to your TdxMemData component. Then while you're running whatever is in the dxMemData component will show up in the grid. This can be real handy for debugging.

On another note, have you looked at the TOvcDbReportView? It seems to do the same thing as the TOvcDataReportView except that it hooks right up to your TdxMemData component and automatically creates your fields based on the fields in the dataset. Then you just have to create the View, set it to AcitveView and open the dataset. It might be worth a look.
J_Maxwell

Oct 19, 2002
9:00 PM
WOW! I never thought about going all database, it was a brilliant idea! Orpheus has a lot of awsome db components!

Thanks,

J_Maxwell

Posting in this forum is limited to members of the group: SITEADMINS, SUBSCRIBERS, MEMBERS.]

the Open Forums!

  Login
If you don't have an account yet, visit the registration page to sign up.

If you already have an account, you may login here:

Username: Password:

  Welcome to the Open Forums!!
Welcome to the Open Forums!!

  Hosted By...

This website is hosted by:

 -
PreparingSons
 - Titus2.com


[ Copyright © the Open Forums! | All times are recorded in ET ]

[ Contact Us ]

Login

Powered by Scif 5.3 build 285 by StandardOut, Inc.