How do i connect datagrid information

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: How do i connect datagrid information

Post by trevordevore » Tue Sep 03, 2013 6:55 pm

You spelled theIndex incorrectly in your "userData" update code that checks if the FindIndex return value > 0. You spelled it "theNIndex". Try fixing that typo and seeing if it works.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Tue Sep 03, 2013 7:59 pm

No I changed it to theIndex but it's still not working, and now it's not removing the line from "activeuser" the icon color changed back but the user is still showing in the grid.

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Wed Sep 04, 2013 9:28 pm

Trevor is it possible that, as I am pulling the information out of the activeuser dg that it has a line index or number that doesn't jive with the user dg and therefore isn't able to update the new data? I only have 20 machines at the most in any classroom so I assign a line number that corresponds to each machine during the logon:machine 1 to line 1, 2 to 2, etc. Also, since I already pull the data from the user dg to log the person on can I somehow store that (the logon ADpin user data Index) information and use it as a means to update the user dg after I add the points. I'm just trying to think of ways to clean up or shorten the code to avoid any pitfalls. Having said that, I think it sounded better in my head then it looks on paper! :)
D

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: How do i connect datagrid information

Post by trevordevore » Thu Sep 05, 2013 1:25 pm

In your code you are looking up the index using the PIN so that should work (assuming you have the pin stored in the user dg). Have you tried debugging to make sure that theIndex > 0 after the FindIndex is performed on the user dg? If you aren't familiar with using the debugger to step through code then this article from the BYU site provides an introduction:

http://revolution.byu.edu/debug/Debugging.php
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Thu Sep 05, 2013 3:21 pm

You know that's the strange thing I'm not getting any more errors and there doesn't seem to be anything off when I debug and step through the code. I am perplexed because the same code works during the login part but then doesn't work for the logout. I went through and checked and re-checked all my variables to make sure I didn't make any mistakes but they all seem fine. I'm sure the pin is right because it comes from the user dg and so does the data that populates the activeuser dg. I still can't understand why the line isn't being removed (from the activeuser dg) now once I log the person off. There must be something going on there or I need to refresh the grid. Anyway, If you think of any other ideas or have a "eureka" moment please let me know and again thank you for all your time and help.

Many thanks,
Don

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: How do i connect datagrid information

Post by trevordevore » Thu Sep 05, 2013 3:51 pm

Ah, I thought you were having problems with the user datagrid, not the active user data grid after the delete.

Your delete call is made after you change the value of theIndex. You need to call DeleteIndex while theIndex is still valid for the activeuser dg. Currently you use the value of theIndex that applies to the users dg.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: How do i connect datagrid information

Post by trevordevore » Thu Sep 05, 2013 3:52 pm

Wait, never mind. Looking back at your example you always delete line 1.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Thu Sep 05, 2013 4:05 pm

Oh, yes i am deleting the line 1 of the activeuser dg. The update problem is the user dg. Before when I was using dispatch and adding a line, (to the user dg) is there a way I can delete the line after I pull it out for the login? This might be a temporary work around until I can figure out how to update using the DataofIndex.
D

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: How do i connect datagrid information

Post by trevordevore » Thu Sep 05, 2013 4:13 pm

You can always delete a row and then add it back in. Looking at your code it looks like the user dg is on a different card that isn't currently open. Perhaps try going to the card with the user dg on it, performing the update, and then going back to the card you are currently on.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Thu Sep 05, 2013 6:02 pm

Still no luck, The dispatch adds the line with the updated data I just end up with a duplicate row. Is there a way to automate deleting the old row with a script? I know it should work the way you update but for whatever reason it's not. I've tried various ways including moving parts of the script in a different order but that didn't work either. I think first get the updated activeuser information then call the user information and set it back into the user dg then delete the line from the activeuser dg. Does this seem reasonable?
Don

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Thu Sep 05, 2013 6:30 pm

I just did a print keys for the user dg and I see something like this:

dob: `02/26/1970`
address: `33 S. 5th`
pin: `1002`
12.00: `theDataA`
12
city: `Missoula`
state: `MT`

and it happens in a couple of different places too. What does this mean? Also, I'm not using all the same fields in each datagrid, would that make a difference?

D

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How do i connect datagrid information

Post by Klaus » Thu Sep 05, 2013 7:42 pm

the key
Dr. Linux wrote:...
pin: `1002`
12.00: `theDataA`
12
...
The key 12:00 (?) obviously contains an ARRAY -> theDataA
At least that's how it looks 8)

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Thu Sep 05, 2013 7:45 pm

Thanks Klaus, but why is it not updating the information for that user. It looks like the information is there just not where it should be. Does it matter that the columns are different? I mean they have columns for the data update but they are not the same as the activeuser dg.
D

Dr. Linux
Posts: 28
Joined: Tue Aug 13, 2013 2:26 am

Re: How do i connect datagrid information

Post by Dr. Linux » Mon Sep 23, 2013 3:10 pm

I think I see now that when I try to update my user dg it creates a sub-array within the data but doesn't update the row. I'm wondering if there is some other code I need to include to make sure it updates the row. If i view the data with Answer it is all correct and everything is there but it doesn't go into the users row. Any suggestions?
Dr. L

Post Reply