e: command setthedata in the data grid api

Sadhu Nadesan sadhu at castandcrew.com
Wed Apr 22 20:55:07 EDT 2009

Aloha, Trevor

Well, I can send you the whole stack, and some sample data and you can 
see what else is going on!?!  But then I'd have to kill you.  Or get an 
NDA.  Ha ha.  Just kidding.  What I mean is, the sample data is all real 
customer data with social security numbers and other confidential info, 
and the application is a 3 tier architecture - rev stack front end, a 
cgi apache middle piece, and a back end SQL database piece, so it 
wouldn't work without all the pieces, and you'd need to be on our 
internal company network or have a VPN connection.  I think what I will 
do is create a simple stack to illustrate the problem.

But then again, maybe it is more straightforward to explain what I am 
trying to do, because, you might have an excellent suggestion and a 
better way!  So here goes.

Goal: delete verified data from the data grid and leave only the error data.

To elaborate, step 1, first the data grid is populated from a spread 
sheet that contains a bunch of info, including names and SSNs and so 
forth, but the source of the data was manual entry and they make 
mistakes.  So we want to find the mistakes. 

Step 2, a verification process runs that performs a number of different 
integrity checks comparing against the data base of record, and color 
codes the data in the grid, depending on if it's close but not exact, 
totally wrong or missing, exactly right, etc.  The kewl thing is that 
thanks to your help the user does not sit there for an undetermined leg 
nth of time watching some spinning wheel or hourglass, they can visually 
see as each integrity check on each cell is performed what color it 
turns, and know how it's progressing along.  Love that.  Scroll into 
view etc.

Next step is manual.  The user has to decide what are the errors that 
need fixing.  For example, there might be a misspelling of a name, the 
correct name is "The Artist Formerly Known As Prince" but the users have 
typed in "TAFKA Prince".  Do we let it go or fix it?

To assist the user in sorting through this data, I'd like a power tool, 
a choice that removes all the lines in the grid that have only valid 
data - only green cells - these cells also have had the token "Verified" 
appended to them (as in the code snippet previously sent).  Once 
distilled down to all errors, the user can manually delete the 
insignificant errors, then go on to the next step of creating a 'data to 
be corrected' report.

So my goal is to build this power tool.

Right now, perhaps due to my fumbling with the API, or not finding an 
example of exactly what would be the best way, I'm doing it like this 
(somewhat over simplified)

Grab all the dgtext of the grid and put it in a container
For each line of the container, if it contains "Verified", delete it
Put the container back as the dgtext of the grid

Now, when I do this without running the integrity checks - meaning, take 
the data out of the grid and then just put it back, it all comes back 
identical to the way it started.  Or if I delete some lines then take it 
out, put it back, again, all is well.

However, after running the verify step (and no mystery, I sent you the 
code), the lines that get back into the grid are split, after each word 
"Verified" a new line starts in the grid, so it appears (not proven) 
that CRs have been inserted.

So back to my question, what is your suggestion of a good way to detect 
lines in the grid that have a certain pattern in one of the cells and 
then delete that line?  I am thinking it would be better to do it in 
place, without taking the data out and putting it back, but I have not 
been able to figure out how yet in just studying the api manual and 
existing examples.

Your input is most appreciated, thank you.


> Hi Sadhu,
> I don't think that SetDataOfIndex is the culprit here. The relevant  
> code for SetDataOfIndex is as follows:
>   if pKey is not empty then
>      put pValue into sDataArray[pIndex][pKey]
>   else
>      put pValue into sDataArray[pIndex]
>   end if
> so the CR must be creeping in somewhere else. What else do you have  
> going on?
> Regards,

More information about the use-livecode mailing list