ListMagic calculated columns

Josep jmyepes at mac.com
Sat Feb 7 03:57:17 EST 2009


Hi,

:) Thanks. It's enought to begin so the idea of use is for invoicing little
documents, no long lists.
I will try to follow your code...

I think that some formula capability for the next version will be great, not
to act as a spreadsheet but yes to do some automated formulas.

Cheers,
Josep M


Jim Bufalini-3 wrote:
> 
> Hi Josep,
> 
> First let me say that Eric designed version 1.1 of ListMagic to make it
> easy
> to display a list of tab delimited data with headers and a lot of other
> functionalities, but not to act as a spreadsheet or report generator like
> you have for database with calculations and breaks and bands, etc. This is
> obvious from the total lack of handlers to set a value into a line or
> item.
> We should probably consider this for version 1.2.
> 
> That said, and while not totally satisfactory, you could do something like
> the following:
> 
> Using your example, let say you had a stack called Pricing, an LM widget
> called LMPricingList and a tab delimited text file called Pricing.txt that
> was in the same folder as your stack that looked like:
> 
> Code	Description	Units	Price	Total	
> J001	ItemA	2	12	24
> J002	ItemB	4	24	96
> J003	ItemC	3	18	54
> 
> 
> First, when you set up ListMagic you should uncheck column drag and drop,
> because you don't want the user dragging the total between the Units and
> Price and set to Select one line only.
> 
> In your preOpenCard or openCard you could put something along the lines
> of:
> 
> ON preOpenCard
>     local tDataTxtFile
>     -----
>     set itemdelimiter to slash -- Or backslash
>     -- Set below to the actual location of your data file
>     put item 1 to -2 of the filename of stack "Pricing" & slash &
> "Pricing.txt" into tDataTxtFile
>     LMPopulate url ("file:" & tDataTxtFile) -- Loads the data. If multiple
> LMs must specify LM name.
> END preOpenCard
> 
> Then you could modify the LMListEdited Command along the lines of:
> 
> ON LMListEdited pWidget,pItem,pLineNo,pOldValue,pNewValue
>   local tCurList, tNewTotal
>   -----
>   set itemdelimiter to tab
>   put LMExtractList(true) into tCurList -- get the entire list including
> hidden columns.
>   SWITCH
>   CASE pItem = 3
>     put pNewValue * item 4 of line pLineNo of tCurlist into tNewTotal
>     break
>   CASE pItem = 4
>     put pNewValue * item 3 of line pLineNo of tCurlist into tNewTotal
>     break
>   DEFAULT
>     -- Change here or add CASE statements to allow changes to other values
>     -- This disallows changing any column except 3 or 4.
>     put pOldValue into item pItem of line pLineNo of tCurList
>   END switch
>   If tNewTotal <> empty then put tNewTotal into item 5 of line pLineNo of
> tCurList
>   LMPopulate tCurList -- again must specify name if there is more than
> one.
>   send "SetLastClickedLineNo" to "LMPriceList" -- use name of your
> LMWidget
> END LMListEdited
> 
> This works, but as I said is not totally satisfactory because if you have
> a
> long list, re-populating the entire list on each edit is time consuming. I
> would disable the check boxes column, if you are going to have long lists.
> The above code is not robust, as it does not have error checking, as in
> the
> case of a user entering non-numeric characters, etc. but just to give you
> an
> idea of how to start.
> 
> Don't forget to save to the text file at some point either manually with a
> button or on closing the card.
> 
> I know Eric added the editing feature at the end and just didn't live long
> enough to think that, by adding this, people might want to change lines,
> columns or items based on an edit. We will look at adding this into
> version
> 1.2. Also, with the addition of the drag and drop feature, should probably
> be able to address columns by column name as well as position.
> 
> Hope this helps.
> 
> Jim
> 
> 
>> -----Original Message-----
>> From: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-
>> bounces at lists.runrev.com] On Behalf Of Josep
>> Sent: Friday, February 06, 2009 11:53 AM
>> To: use-revolution at lists.runrev.com
>> Subject: RE: ListMagic calculated columns
>> 
>> 
>> Hi Jim,
>> 
>> I need something like this example:
>> 
>> Code	Description	Units	Price	Total
>> J001	Item A		2		12		24(*)
>> 
>> (*) Column Total will be calculated by col "Units" * "Price", and if
>> the
>> user edit the values of Units or Price the column Total will be
>> calculated.
>> Other thing is that control the column that the user are editing..
>> 
>> Reading the scripts I found:
>> 
>> on LMListEdited pWidget,pItem,pLineNo,pOldValue,pNewValue
>>    DisplayPrompt "LMListEdited - item" && pItem && "of line" && pLineNo
>> &&
>> "-" && pOldValue && ">" && pNewValue
>>    -- sent when an item has been edited and changed in the list
>>    -- pWidget is the long ID of the widget
>>    -- pItem is the item number
>>    -- pLineNo is the line number
>>    -- pOldValue is previous value
>>    -- pNewValue is new vlaue
>>    -- write your code here:
>> 
>> end LMListEdited
>> 
>> Any that I put inside of this script, thinking that this is correct
>> handler
>> not work.
>> If I use "rawkeyup" message I can intercept the key pressed but nothing
>> more... sorry but I'm stoped here.
>> 
>> 
>> Hi Josep,
>> 
>> I assume you are saying you have handlers you have added into the card
>> script that are not working?
>> 
>> Can you show a sample of the code that is not working?
>> 
>> Thanks!
>> 
>> Jim Bufalini
>> 
>> 
>> --
>> View this message in context: http://www.nabble.com/ListMagic-
>> calculated-columns-tp21864343p21881420.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 

-- 
View this message in context: http://www.nabble.com/ListMagic-calculated-columns-tp21864343p21886231.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the Use-livecode mailing list