Datagrid SetDataOfLine problem

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

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Datagrid SetDataOfLine problem

Post by phaworth » Sun Apr 25, 2010 11:40 pm

I am using the following code in a script in a datagrid group to put a new value into a column in the datagrid:

Code: Select all

put "SetDataOfLine" && the dgHilitedLine of me & comma & quote & "DBD_Act" & quote & comma & quote & myDate & quote into myMessage
send myMessage to me in zero seconds
put "RefreshLine" && the dgHilitedLine of me into myMessage
send myMessage to me in zero seconds
I looked at the contents of myMessage right before the first send and they were:

SetDataOfLine 10,"DBD_Act","2010-04-25"

Right after the first send, I used the message box to display the dgText of the group and the line that was just updated was all blank (there were values in all the columns prior to the SetDataOfLine.

There are 6 columns in the datagrid and the one I am updating is the last column.

What am I doing wrong?

Thanks,
Pete

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

Re: Datagrid SetDataOfLine problem

Post by trevordevore » Mon Apr 26, 2010 7:15 pm

Does your code work if you take out the send?

Code: Select all

SetDataOfLine dgHilitedLine of me, "DBD_Act", myDate
RefreshLine the dgHilitedLine of me
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

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Datagrid SetDataOfLine problem

Post by phaworth » Mon Apr 26, 2010 7:38 pm

Yes, thank you Trevor.

This leaves me confused as to when the send in zero seconds is necessary and when the datagrid commands can be used directly. I had thought that I needed the send because the code is in a script in the datagrid group?

Thanks,
Pete

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

Re: Datagrid SetDataOfLine problem

Post by trevordevore » Mon Apr 26, 2010 7:49 pm

In the current version of Rev you can't call RefreshList without using send in time and you can't delete the last line of the data grid without using send in time. The latter limitation has been removed in the forthcoming Rev 4.5.

As to why your code doesn't work with send? I'm not sure. But while on the subject of send I will point out that it is good practice to stick parameters into variables and then use the variable names in the send string. Otherwise you can end up with unexpected behavior depending on the values of the parameters (commas in the parameters will split a single parameter into multiple parameters using the technique you are using). See this lesson for additional information send and params: How to send messages to an object using the send command
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

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Datagrid SetDataOfLine problem

Post by phaworth » Mon Apr 26, 2010 8:34 pm

Thanks for the tip on using send.
Pete

Post Reply