Hilite Form Grid row based on time field

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: Klaus, FourthWorld, heatherlaine, kevinmiller

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Thu Mar 14, 2019 5:09 pm

After looking and reading about table fields, I don't see how I could get the data to look anywhere like my first pic. Can that be done with a table field?

Dave

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Thu Mar 14, 2019 9:58 pm

Hi.

So much fun to make kluges. Thank you for allowing me to do something other than work.

Try the attached stack. Field 1 is a table field. There is some test text in fld 2. I think it is necessary to insert hard text dividers in the loading process, since I could not think of any other way to make them scroll.

You can change the text in fld 2 to see it load into fld 1

A data grid can do this in its sleep. But that gadget is complex.

Craig
Tablefield kluge.livecode.zip
(3.72 KiB) Downloaded 7 times
Last edited by dunbarx on Fri Mar 15, 2019 1:52 pm, edited 1 time in total.

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Thu Mar 14, 2019 11:32 pm

right cool! I can't look in depth now as i am at work but later and im stoked now..perhaps as much as you were when making it..lol

Dave

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Fri Mar 15, 2019 5:11 pm

Indeed it is a very cool technique. I played with it..change colors, the html line code to 95 (looked nicer) and its width. Now some questions.

1)It appears as if I have to format the data from the csv before hand. I can do that with excel no problems..is this true or is there some other trick up your sleeve.

2) Also as mentioned in a previous post, i have chosen to leave the dancers names off this list, but would like to, upon a click, tap on a certain row show the detail of that dance..all the data from that dance. I think that is why i went to the datagrid, for the sql and searching capabilities. I understand it is a "beast" as someone said, but i think with a little help I could get it to do what I want. I know i shouldn't run before learning how to walk as the saying goes but with very little knowledge, just reading and watching I got it to fetch the data from a sqlite database format it the way i wanted. I couldn't get it to extract the record i wanted. Also I would like it to highlite the current dance based on the dance time in the record compared to the system time.

You have been a great help with this. that technique with the looping through the 3 lines adding the separator is cool. I guess this is why you called it a kluge (workaround).

dave

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Fri Mar 15, 2019 8:28 pm

Hi.

1- CSV should be outlawed. The likelihood that commas might be embedded in the wrong place, or conversely, that one MUST NOT have commas in the wrong place, makes that protocol dangerous at best. In other words, it should be a law that we do not use a very common character as a delimiter.

If you do not have errant commas, then import your data into LC and simply:

Code: Select all

replace comma with tab in yourData
Nobody seems to mess with carriage returns, fortunately. Now you have properly formatted data for direct entry into the table field.

2- To do that you have to fool the table field a little. It works by creating a new phantom field that overlies the "cell" you clicked on. That field is sized according to the size of the "cell", and a text entry into that field is loaded into the appropriate item in the appropriate line. This makes it more complicated to determine where you clicked.

So why not use a normal scrolling field? The same properties that make the look and feel of the table field can be applied to a scrolling field, and that object is much simpler. Check out the new version of that stack. Click on any line in the scrolling field in the upper left of the card. The script of that field contains only two lines, and the first one is just to show you something a bit intermediate. There is a custom property of that field (the "danceData") that you can look at and embellish.

Craig
Tablefield kluge v.2.livecode.zip
(4.18 KiB) Downloaded 10 times
Last edited by dunbarx on Fri Mar 15, 2019 8:33 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Fri Mar 15, 2019 8:31 pm

Just so you know, this back and forth has been all about me pushing you to back to the basics, whereas you started way, way out there, with SQL and data grids.

Your choice. I recommend doing it my way. 8)

Craig

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Fri Mar 15, 2019 9:08 pm

i have to apologize. Firstly, i'm not trying to jump the gun you are a yoda, im the student. My mistake in saying csv. my data is tab delimited as that is the way i read to do it. secondly, there is not typing into fields, merely static data..display only. Im the only one. I get it in pdf or excel then convert that to tab delimited. If in pdf i extract the data..just one extra step.

Dave

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Fri Mar 15, 2019 9:45 pm

OK.

As built so far, there is no typing into any fields. The loading of the data is from an external file, as it should be, though it does not have to be. You may want to edit within the field itself.

Clicking into a field only brings up whatever is associated with the clickLine, however that is done. In the example it is the contents of the line of the custom property. You click on line 3, you pull up line 3 of the custom prop. The "3" could be used to select any sort of information stored anywhere; it is just an index.

The question still is: are we done functionally? That is, will a simple scrolling field do all you need it to? Building it is a nice little project. If you want to expand in the future with all that other fancy stuff, go ahead, but you really ought to do it the easy way first.

Trust me.

Craig

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Sat Mar 16, 2019 12:46 am

Yes and it works fine. If added some data of mine. I don't understand the random click thing, so i added this to the field\

on mouseUp
#do "put random(99) into" && the clickText
select the clickLine
put the value of the clickLine into textOfClickedLine

answer textOfClickedLine
#answer line word 2 of the clickline of the danceData of me
end mouseUp

is this ok

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Sat Mar 16, 2019 2:03 am

Everything is OK.

Put code between the code tags. (</>)

The "do" line is a throwback to an earlier age, when you could not just:

Code: Select all

put random(99) into the clickChunk
But now you can. One day we will talk about things that you cannot, like:

Code: Select all

on mouseUp
   get word 2 of fld 1
   find it in fld 1
   put the foundChunk into ff
  -- put random(99) into ff  -- does not work
  do "put random(99) into" && ff --works
end mouseUp
You can play with this if you want. But we are off track. I wondered when I posted if you would trip over:

Code: Select all

answer line word 2 of the clickline of the danceData of me
I should have written (though it is identical, just easier to parse:

Code: Select all

answer line (word 2 of the clickline) of the danceData of me
But you seem not to have. Good.

Everything is OK. What will you do next?

Craig

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Sat Mar 16, 2019 3:30 am

That line did give me some slack at first but then stopped. Anyways i posted a pic of what i have on the screen. As you can see when i click on one line it displays one line, going back to some earlier posts, i would like to have it light up all three lines (that is a chunk i think) and display the data in a nicely formatted display. perhaps on another screen. Also don't forget that the dancers names are not included right now in this list as there are some dances with lots of dancers.

Again your the best..I never really had a chance in my life to sit down and try something like this. its fun.

Dave
Attachments
Capture2.PNG

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Sat Mar 16, 2019 5:29 am

Since you know the line clicked on, you also know which group of four it belongs to (remember the horizontal line makes four). That is a great advantage of a well ordered dataSet. It cuts out, and through, a lot of finagling.

So if you click on line 23, you know you are in the triplet 21- 24. Look up the "hilitedLines" in the dictionary.

Craig

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Sat Mar 16, 2019 1:34 pm

ok will do. my wife thinks i'm nuts. first thing i do when i get up is look at this. lol

tbcomputerguy
Posts: 16
Joined: Tue Mar 12, 2019 6:02 pm

Re: Hilite Form Grid row based on time field

Post by tbcomputerguy » Sat Mar 16, 2019 6:44 pm

i was thinking after reading a bit that if i can isolate the "separater" line by say using "if theLineNo mod 4 = 0 then hilite the 3 lines above that line. if not then find that line somehow. Or group the triplet as said it was and then hilite it.

Dave

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hilite Form Grid row based on time field

Post by dunbarx » Sun Mar 17, 2019 2:18 am

Hmmm.
if i can isolate the "separater" line
Aren't you clicking in the field to gather information about the particular set of interest? You already have done all you need to "isolate". LC knows where you clicked. You can do the math. Done.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”