using lists

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
Chad
Posts: 5
Joined: Fri Oct 29, 2010 1:06 pm

using lists

Post by Chad » Mon Nov 08, 2010 10:58 pm

I am developing a time sheet application to replace the paper versions we use at the moment. What I want to be able to do is highlight the background of a line in the list of timesheets ( each sheet is a card and the lists is made up of the card names) based on if the data has been exported or not. If the data has been exported I want the background to be green and for those not yet exported to be red. The code I have is
on setexportedcolour
repeat with thisRecord = 1 to the number of cards
put the hilite of button "Record_Exported" of card thisRecord into hasBeenExported
if hasBeenExported is True then
set backgroundColor of the line (the number of this card) of field "List" to "Green"
else
set backgroundColor of the line (thisRecord) of field "List" to "red"
end if
end repeat
end setexportedcolour

The issue I have is that this will only work on the current card and the settings are not then passed to the next card when it is opened.

Any thoughts

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: using lists

Post by bn » Mon Nov 08, 2010 11:51 pm

Hi Chad,

welcome to the Forum.

I don't quite get where the lists are. Are they on the same card as the buttons exported/not exported are? Or are they on the first card where you have a List of all the other cards and want to hilite the exported/non exported cards on the list of the first card?

It would be the easiest way to just post a zipped version of a short example stack here.

In your code I noticed:

Code: Select all

set backgroundColor of the line (the number of this card) of field "List" to "Green"
since you dont go anywhere in your repeat loop "this card" would always be the card where you started from.

In the else part of the conditional you say:

Code: Select all

set backgroundColor of the line (thisRecord) of field "List" to "red"
this would probably correctly point to the record thisRecord, which you loop through in your repeat loop.

From your code the field "List" has to be on one card since you dont specify a card for the field, so I dont understand
this will only work on the current card and the settings are not then passed to the next card when it is opened
Do you have a background group for the list field ? If so did you check sharedText for the field?

regards

Bernd

Chad
Posts: 5
Joined: Fri Oct 29, 2010 1:06 pm

Re: using lists

Post by Chad » Tue Nov 09, 2010 7:34 am

Thanks, Bernd

I have attached my first attempt at this project and have tried document everything based around the examples I have pulled from various sites. Have a look at the project and the list I am talking about is part of the background of each card(record) each line refers to a Daysheet (card) within the stack.

If you enter in numbers into the NTP field and then move from that field the card name will be updated and if data in the card hasn't been exported then the background of the list with the card name should be red but only that line.

thanks for your time
Attachments
ElectronicDaybook.zip
(38.67 KiB) Downloaded 232 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: using lists

Post by bn » Tue Nov 09, 2010 11:12 am

Chad,
without understanding completely the project the offending line is

Code: Select all

set backgroundColor of the line (the number of this card) of field "List" to "Green"
if you change that to

Code: Select all

set backgroundColor of the line (thisRecord) of field "List" to "Green"
then it works

that was what I was trying to say in my first reply, maybe I was a little cryptic about it.

this code works in your stack script

Code: Select all

on setexportedcolour
   repeat with thisRecord = 1 to the number of cards
      put the hilite of button "Record_Exported"  of card thisRecord into hasBeenExported
      answer hasBeenExported
      if hasBeenExported is True then
         set  backgroundColor of the line (thisRecord) of field "List" to "Green"
      else
         set  backgroundColor of the line (thisRecord) of field "List" to "red"
      end if
   end repeat
end setexportedcolour
This looks like a nice project. You might want to check if, when actually used, it might not easily grow fast and the number of record go into the thousands. If so some sort of database as a storage might be faster, or saving the data in custom properties. Rev slows down as a data repository once you get beyond 5000 or so cards. You would use the cards as views for your data, the data being actually in custom properties or a database.

regards
Bernd

Chad
Posts: 5
Joined: Fri Oct 29, 2010 1:06 pm

Re: using lists

Post by Chad » Tue Nov 09, 2010 11:27 am

Thanks Bernd,
I have been looking at the same code and missing it each time, when I look at my notes now I can see that I was making the same error with the red highlighting previously. The intention is to regenerate a new Daybook each year so there should be no more than 250 cards in each Day Book.

Do you think a Datagrid would be a neater way of doing this ?

Thanks heaps for advice

Chad

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: using lists

Post by bn » Tue Nov 09, 2010 12:01 pm

Chad,

I think you are fine with this approach. But then I find the datagrid powerful but not an easy beast.

As you said you transferred your paper-based version to an computer-based version. I would think about what the computer can do to reduce data entry. People dont like to type, whereas writing is a lot easier for them. If you have repetitive data that you could put into a pull-down menu or some such object it would make data entry easier and more consistent. Just a thought.

regards

Bernd

Chad
Posts: 5
Joined: Fri Oct 29, 2010 1:06 pm

Re: using lists

Post by Chad » Wed Nov 10, 2010 1:22 am

Bernd, Thats is the next part of my journey into programming in LiveCode. I want to now connect to excel and pull the customer data, the NTP number and job titles from the planning file. This I have been thinking will populate an array which will hold the information by the index key which will be the NTP Number as it is a unique number.

I have tried using VBScript but don't understand this well and how to pass the information back. I am thinking of using the OBDC driver to access excel and then pass the information back. I stopped here and started to get all the other areas of the project sorted out. I still have the export function to finalise and the import function.

With the import function my blocker in the VBScript is how to pass a different file name to look for in which the data is stored. I can do it if the file name stays the same and then I don't grasp how the data can be passed back. I understand the OBDC method but I'm not sure it is as neat as the VBScript.

I haven't really explored this yet and that is the next step over the next few days to try and sort out.

Any thoughts would be appreciated

Chad,

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: using lists

Post by bn » Wed Nov 10, 2010 1:51 am

Chad,
sorry, I am on a Mac, so I dont know anything about VBScript. Maybe someone can chime in.
I don't grasp how the data can be passed back
if it is anything like applescript from Livecode then you collect your data in the VBScript into a variable and at the end of the script you say "return myVariable" or whatever syntax VBScript uses to return a value. On the Livecode side you check" the result" for the returned data.

Code: Select all

do myCompleteVBScript as vbscript
put the result into myLiveCodeVariable
errors would show up there also, you would want to check that. I would give it a try like this with little data and see if it works.

And for passing a different file name, it is probably again like in Livecode applescript.
I would try this. Make you VBScript to use a variable for the fileNameAndPath. In Livecode I just construct a declaration of the fileNameAndPath variable with the path and name of the file/files. Then I concatenate the declaration of the variable and the script into myCompleteVBScript and send that off as external script, in your case VBScript.
I am pretty shure that is the way it works. But who knows. :)

regards

Bernd

Post Reply