How do i connect datagrid information
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How do i connect datagrid information
Hello all,
I have been learning LiveCode for a month or so and I have ran into a datagrid issue. Probably not a big shock to you guys. I have 3 datagrids, one is a user editor, one is a machine editor and one is the input and output. So what i have is a array that i collect user info (name, address, etc.) the machine editor (machine no., type, location...) which is a list of computers that users can logon and off to. The input/output is where I want the user to select the machine, identify the user and track their usage by an id number and display it in the input/output grid. Now my question is how do I assign a unique id to each user as i add them and then can i pull their name from the id (user grid) and display it on the input output grid and track their usage in the machine grid. I thought i would try it as an array since i am the only one keeping track of this. I didn't want to go the database route just yet. Any ideas? I am able to populate my users and machines, and i use the ask and answer dialogs to put info into the input output grid. So now how do i share between the three?
I have been learning LiveCode for a month or so and I have ran into a datagrid issue. Probably not a big shock to you guys. I have 3 datagrids, one is a user editor, one is a machine editor and one is the input and output. So what i have is a array that i collect user info (name, address, etc.) the machine editor (machine no., type, location...) which is a list of computers that users can logon and off to. The input/output is where I want the user to select the machine, identify the user and track their usage by an id number and display it in the input/output grid. Now my question is how do I assign a unique id to each user as i add them and then can i pull their name from the id (user grid) and display it on the input output grid and track their usage in the machine grid. I thought i would try it as an array since i am the only one keeping track of this. I didn't want to go the database route just yet. Any ideas? I am able to populate my users and machines, and i use the ask and answer dialogs to put info into the input output grid. So now how do i share between the three?
Re: How do i connect datagrid information
Hi.
Do I understand that you want to lock a unique ID to a record of data, and then relocate and maintain that data when you load and unload from one dataGrid to another datagrid? If so, you seem more than capable of assigning unique ID's, perhaps composed based a master key held in a custom property whenever a new record is created. Is it the ID assignment you are asking about? Is it keeping the records between DG's intact?
Once assigned, you can always search a datagrid for the ID, and pull the whole line (record) when you find it. Or you can pull from any other DG as well. It seems that you would use the ID to manage all three, since that ID is common to the records of all three.
Or do I have this totally wrong?
Craig Newman
Do I understand that you want to lock a unique ID to a record of data, and then relocate and maintain that data when you load and unload from one dataGrid to another datagrid? If so, you seem more than capable of assigning unique ID's, perhaps composed based a master key held in a custom property whenever a new record is created. Is it the ID assignment you are asking about? Is it keeping the records between DG's intact?
Once assigned, you can always search a datagrid for the ID, and pull the whole line (record) when you find it. Or you can pull from any other DG as well. It seems that you would use the ID to manage all three, since that ID is common to the records of all three.
Or do I have this totally wrong?
Craig Newman
Re: How do i connect datagrid information
Thank you dunbarx,
I have three datagrids, one is a list of users, two is a list of machines and three is where i want to pull one and two together. I am assigning a pin # to each user, and each machine has a number. For machine 1, I use an ask dialog for the user pin, i want to then take the pin # and search my user datagrid and pull up their name and then list the machine they are on in the 3rd display grid. I keep seeing this hilighted row property but i am just searching by an assigned key. I thought about using the index # as the pin but I'm not sure how to display it in my grid or refer to it in script. I've only been using LiveCode for a month or so. I am stll learning.
the user clicks the computer 1 icon:
ask "what is the user pin"
put it into thePin
#now i have thePin in a variable, so I want to take the pin and search my user grid and find the user by their pin and show their name and other data from their row in the user grid. I also am trying to keep track of computer usage and statistics but that can come later. Let me know if this isn't clear I can paste some code but mostly it is ask and answer dialogs that put the responses into the display grid.
I like your custom property idea but I'm not sure how to implement it. I would like to assign a unique id when a user is added then i could pull their data. I'm still not sure how to script the search from my ask answer dialogs to then retrieve the data. I only need some colums from the user not everything in the row.
I have three datagrids, one is a list of users, two is a list of machines and three is where i want to pull one and two together. I am assigning a pin # to each user, and each machine has a number. For machine 1, I use an ask dialog for the user pin, i want to then take the pin # and search my user datagrid and pull up their name and then list the machine they are on in the 3rd display grid. I keep seeing this hilighted row property but i am just searching by an assigned key. I thought about using the index # as the pin but I'm not sure how to display it in my grid or refer to it in script. I've only been using LiveCode for a month or so. I am stll learning.
the user clicks the computer 1 icon:
ask "what is the user pin"
put it into thePin
#now i have thePin in a variable, so I want to take the pin and search my user grid and find the user by their pin and show their name and other data from their row in the user grid. I also am trying to keep track of computer usage and statistics but that can come later. Let me know if this isn't clear I can paste some code but mostly it is ask and answer dialogs that put the responses into the display grid.
I like your custom property idea but I'm not sure how to implement it. I would like to assign a unique id when a user is added then i could pull their data. I'm still not sure how to script the search from my ask answer dialogs to then retrieve the data. I only need some colums from the user not everything in the row.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: How do i connect datagrid information
A data grid has the FindIndex/FindLine commands that will search the data inside the data grid. Search for FindIndex on this page:
http://lessons.runrev.com/s/lessons/m/d ... a-grid-api
So your syntax might look like this:
If theIndex > 0 then you can extract the user data from the data grid using the dgDataOfIndex.
At this point you have an array of the user data for that particular user.
As a side note, the data grid is just storing your data as an array. You can access this array using the dgData property.
You can then search that array using one of the techniques described here:
http://lessons.runrev.com/s/lessons/m/4 ... h-an-array
http://lessons.runrev.com/s/lessons/m/d ... a-grid-api
So your syntax might look like this:
Code: Select all
-- Find pin
dispatch "FindIndex" to group "MyUserDataGrid" with "pin", theAskDialogPinNumber
put the result into theIndex
Code: Select all
put the dgDataOfIndex[theIndex] of group "MyUserDataGrid" into theUserDataA
As a side note, the data grid is just storing your data as an array. You can access this array using the dgData property.
Code: Select all
put the dgData of group "MyDataGrid" into theDataA
http://lessons.runrev.com/s/lessons/m/4 ... h-an-array
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
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
Re: How do i connect datagrid information
However don't be scared of databases, SQLite is embedded in Livecode, you don't need to install anything. 

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: How do i connect datagrid information
Perhaps I am not following this correctly but what will you do if more than one person just happen to use the same pin# (I think you mentioned they are picking their own pin) If my interpretation is wrong then I apologize.
Re: How do i connect datagrid information
never mind I reread the post and you said you were providing the pin please disregard my inane comment above sorry...
Carry on
Carry on
Re: How do i connect datagrid information
Thank you guys for all the great help and btw Trevor everything worked just fine. Thank You!!! The only issue i am having is that my users are students and part of what i'm tracking is grades and improvements. One of my user columns is a rank 1 - 5 but the numbers represent different values: for ex. a 5 = 1.5, 4 = 1 and so on, I tried to declare the ranks as variables. Then as i pulled them out of the dg I assigned them a new variable name thinking that the value of the variable would be what i declared. Then i tried to determine the percentages but keep getting an error that says there is a problem with my right (my assigned variable or varB) variable.
put the dgText of group "activeuser" into utemp
set the itemdel to tab
put item 8 of line 1 of utemp into varB # this shows as a 5 but does not show my declared value at the top of my script
answer (varA * varB)
it sees the number if i display it but doesn't see that a 5 = 1.5
Once I get the new value it will go back into a column that tracks points
I want some privacy for the other students so I can't just put the rank values in the column
I'm sure there must be some logical way to fix this. I just want the ranks to represent assigned values for the math part of this. Any suggestions?
put the dgText of group "activeuser" into utemp
set the itemdel to tab
put item 8 of line 1 of utemp into varB # this shows as a 5 but does not show my declared value at the top of my script
answer (varA * varB)
it sees the number if i display it but doesn't see that a 5 = 1.5
Once I get the new value it will go back into a column that tracks points
I want some privacy for the other students so I can't just put the rank values in the column
I'm sure there must be some logical way to fix this. I just want the ranks to represent assigned values for the math part of this. Any suggestions?
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: How do i connect datagrid information
I'm not sure I understand how you have your code set up. Are you saying that you have a variable named "5" and you want varB to show the value of the variable "5"?
What I would do is create a lookup table of some sort. One option:
What I would do is create a lookup table of some sort. One option:
Code: Select all
put 1.5 into theLookupA[5]
put 1 into theLookupA[4]
put the dgText of group "activeuser" into utemp
set the itemdel to tab
put theLookupA[item 8 of line 1 of utemp] into varB # varB should contain the number 1.5 if item 8 of line 1 of uTemp is 5
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
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
Re: How do i connect datagrid information
Thank you again Trevor and yes this is exactly what I am trying to do. I'm putting the 5 into the dg but it represents a 1.5%. I think the lookup table is a good option and I should be able to implement it. Now when i put the new value (the result of varA * varB) into points, is there a way to be sure it adds the points each time the user logs on and completes their task. It is a cumulative value and grows with each assignment. I can't find a specific example of how to add values as they go into the datagrid. I think if I just set the new value in, it will replace the old value not add the two values "is that right?"
Don
Don
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: How do i connect datagrid information
Correct. The data grid won't manipulate any values behind your back. It just takes whatever data you assign to it.
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
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
Re: How do i connect datagrid information
Gotcha, so I would have to code it so that the values are added then put into the dg. I would need to pull the old value out and then add the new value to it then put it back in order to keep adding the points up. I think I am starting to understand some of this and I have to say I really like the DataGrid it is my White Whale so to speak. (haha!) I am going to keep at it.
I have the basic program now and if I can just add points as we go along that should do it. I will continue to learn more and try more complex operations as time allows. One feature I want to add is the ability to move a user to a different machine with all their data. I think if I use your Lookup table and list the individual machines it might work. (wish me luck!)
Thank you again for your help,
D
I have the basic program now and if I can just add points as we go along that should do it. I will continue to learn more and try more complex operations as time allows. One feature I want to add is the ability to move a user to a different machine with all their data. I think if I use your Lookup table and list the individual machines it might work. (wish me luck!)
Thank you again for your help,
D
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: How do i connect datagrid information
You're welcome. And good luck 

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
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
Re: How do i connect datagrid information
Well i didn't get too far. I can't seem to add the new points information back into the user dg. I tried the FindIndex approach to locate the specific user but it just put in a blank line. Is there a way I can pull the user out with the pin and once the points are added put them back using the same array that is created. In other words if I get the person using their pin I already have their data I just need to add their points once they log out then put them back. I'm just not sure how to approach the process in terms of syntax. Could you show me some examples?
Last edited by Dr. Linux on Wed Aug 28, 2013 9:24 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: How do i connect datagrid information
Can you show the relevant portions of your code that you are currently using and then we go modify from there?
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
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