Page 1 of 1
[help] What's wrong with this code ?
Posted: Thu Jun 18, 2015 10:21 pm
by shawnblc
I am able to write data to the datagrid, but when I submit a second time my first entry is replaced. When I change my code to this nothing is added though:
Code: Select all
put tDate into theRowData
put tFacility into theRowData
put tCategory into theRowData
put fld "lblLink" into theRowData
put the dgNumberOfLines of grp "DataGridFiles1" of stack "Filing Cabinet" + 1 into theLineNo
dispatch "AddLine" to grp "DataGridFiles1" of stack "Filing Cabinet" with theRowData, theLineNo
On my main stack I'm selecting my file and date, on my substack I'm adding the information. "Filing Cabinet" is my substack.
Re: [help] What's wrong with this code ?
Posted: Thu Jun 18, 2015 10:30 pm
by dunbarx
Hi.
You rewrite the contents of the variable "theRowData" three times. Is this intended?
AddLine requires a tab delimited string. Is there data in such a string when you dispatch?
Craig Newman
Re: [help] What's wrong with this code ?
Posted: Thu Jun 18, 2015 10:51 pm
by shawnblc
dunbarx wrote:Hi.
You rewrite the contents of the variable "theRowData" three times. Is this intended?
AddLine requires a tab delimited string. Is there data in such a string when you dispatch?
Craig Newman
Let me show you what I'm trying. See image. No, I don't have a tab delimited string. I was trying to incorporate a few examples I've found. If you look at the image. The image on the left is my "Main Menu" stack. I select the file and successfully upload it to the server. Once the upload is completed I can use dispatch to populate the datagrid in the substack (previous code), but was always overwritten. So the above code I was attempting to create a new line for each document.
When I use this code I can add 1 single line each new entry overwrites the previous (not what I want).
Code: Select all
put 1 into theLineNo
put tDate into theDataA[ 1 ][ "date" ]
put tFacility into theDataA[ 1 ][ "facility" ]
put tCategory into theDataA[ 1 ][ "category" ]
put fld "lblLink" into theDataA[ 1 ][ "documentLink" ]
set the dgData of group "DataGridFiles1" of stack "Filing Cabinet" to theDataA
dispatch "AddLine" to group "DataGridFiles1" of stack "Filing Cabinet" with theDataA, theLineNo
put the result into theNewIndex
Re: [help] What's wrong with this code ?
Posted: Fri Jun 19, 2015 1:12 am
by hilton
put tDate into theDataA[ 1 ][ "date" ]
If I understand the code, the index needs to change for each line else it will overwrite. You need to have
Code: Select all
put tDate into theDataA[ 1 ][ "date" ]
put tDate into theDataA[ 2 ][ "date" ]
put tDate into theDataA[ 3 ][ "date" ]
etc....
Re: [help] What's wrong with this code ?
Posted: Fri Jun 19, 2015 1:16 am
by shawnblc
hilton wrote:put tDate into theDataA[ 1 ][ "date" ]
If I understand the code, the index needs to change for each line else it will overwrite. You need to have
Code: Select all
put tDate into theDataA[ 1 ][ "date" ]
put tDate into theDataA[ 2 ][ "date" ]
put tDate into theDataA[ 3 ][ "date" ]
etc....
The problem with that is I don't know how many docs there will be, there could be several hundred / thousand. The user submits the documents, which are immediately uploaded to the server.
This is what I had previously:
Code: Select all
put 1 into theLineNo
put tDate into theDataA[ 1 ][ "date" ]
put tFacility into theDataA[ 1 ][ "facility" ]
put tCategory into theDataA[ 1 ][ "category" ]
put fld "lblLink" into theDataA[ 1 ][ "documentLink" ]
Re: [help] What's wrong with this code ?
Posted: Fri Jun 19, 2015 5:51 am
by D4vidrim
shawnblc wrote:
The problem with that is I don't know how many docs there will be, there could be several hundred / thousand. The user submits the documents, which are immediately uploaded to the server.
Why don't you count the number of record on that data grid first, then you add 1 to that number then you can insert the new record.

Re: [help] What's wrong with this code ?
Posted: Fri Jun 19, 2015 8:00 am
by shawnblc
D4vidrim wrote:shawnblc wrote:
The problem with that is I don't know how many docs there will be, there could be several hundred / thousand. The user submits the documents, which are immediately uploaded to the server.
Why don't you count the number of record on that data grid first, then you add 1 to that number then you can insert the new record.

Let me see if I can figure that out. I'll update in a few minutes. Hmmmmm.
Re: [help] What's wrong with this code ?
Posted: Fri Jun 19, 2015 8:04 am
by SparkOut
You've been trying to AddLine with a (broken) array. In your very first post you might have succeeded if you had a properly constructed array of data, and then instead of dispatching "AddLine", dispatching "AddData" would probably have worked.
You then went on to make an array, which you then used to populate the whole datagrid, which worked, but the AddLine part failed. That's why it looked like you were overwriting with the new line - it wasn't, but you had already recreated the entire datagrid contents with that single line of data.
Then you say you don't know how many rows there are in the datagrid to be able to insert a correct new line number, but you already got that in the first post.
When you add data with an array, the array index should not match the line number, when you set the whole datagrid contents using an array, each array index will be a new record of data. You need to pass the new line number but not by the array index.
Code: Select all
put tDate into theDataA[1]["date"]
put tFacility into theDataA[1]["facility"]
put tCategory into theDataA[1]["category"]
put fld "lblLink" into theDataA[1]["documentLink"]
put the dgNumberOfLines of grp "DataGridFiles1" of stack "Filing Cabinet" + 1 into theLineNo
dispatch "AddData" to grp "DataGridFiles1" of stack "Filing Cabinet" with theDataA, theLineNo
put the result into theNewIndex
You could alternatively do this with AddLine but that would need a tab delimited string, not an array. But in no case would you need to overwrite the dgData with an entirely new content.