Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I base a grid on an array?
Message
From
30/04/1999 02:42:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/04/1999 12:16:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00213274
Message ID:
00213788
Views:
35
>>Stephen's suggestion is a way. Second adding a "calculated column" is another way.
>
>Re: "adding a "calculated column." Are you referring to a calculated field in the SQL field list? That would be a nice solution. I started to write a UDF which runs an SQL select to calculate the sum of all detail items up the current one but I haven't tried it yet. Is this what you are imagining?
SQL field list ? If you mean the original data was collected via SQL yes can be with some modification. ie:
select credit, debit, 0*0xFFFFFFF as balance ;
   from mytable ;
   into cursor grdCursor ;
   nofilter
A scan...endscan would fill the balance (I think easier to do than designing a UDF for select). This way in grid for 1st and 2nd columns you would add some lostfocus code (and gotfocus to save value before change - assuming you're not performing tableupdate()) to replace "balance".
>
>I also thought about a sub-select to do the same thing but I couldn't see any way to do this.
>
>
>
>>Stephen's suggestion is better IMHO because you initialize the values once via a scan..endscan and change only the records that are current and below in the grid as credit or debit changes.
>
>The problem I have with Stephen's approach is that it puts unsaved data into a table buffer. (Unless I'm missing something.) Seems error prone.
>
This approach is still better IMHO. Buffered data is not SQL selected in calculations true. But you wouldn't need it.
- Scan ... endscan at entry.
- If credit or debit changes calculate difference (delta) for row.
- Add delta value to all balance from current rec to bottom.
(replace balance with balance+delta rest)
- Return to row.
This approach works fast even in FP2x :)
>Thanks for thinking about this.
>
>Peter
If not solved by monday I could send a ready example (don't remember where it's for the moment).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform