|
|
||||||||
|
|
|
|
|
|
|
|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Pro |
First, let me say that I completely don't know what I'm doing when it comes to either F-Script or Cocoa. I'm only slightly less lost when it comes to building reports (on the bright side, I do understand the Merge engine pretty well). That said, I've spent several hours kludging together a report, but I've got one small issue that I can't seem to resolve.
To get the sum of a bunch of tasks AND be able to round them to the tenth of an hour, I use the following F-Script: TOTAL := element valueForKeyPath:@ 'parent.parent.parent.parent.parent.parent.reportData.objects.@sum.durationSeconds'. ((TOTAL/360) ceiling) * 0.1. It works just like I want it to, but the result is formatted with curly braces around it, like this: {125.3} I'm sure it has something to do with the return type, but I just can't seem to figure it out. Any help would be greatly appreciated! |
||
|
|
Pro |
I think your f-script is returning an array because TOTAL is an array.
Try foo := ((TOTAL/...). foo at: 0. "Returns the 0ths elment of foo". Disclaimer: My OS X programming knowledge & skills sound similar to yours. |
|||
|
|
Pro |
Doug,
You are the man. Don't know why I couldn't figure that one. It should have been obvious, but I guess I was confused as the Cocoa documentation (which I consulted to get the Sum function) indicated that the return type would be an NSNumber type. In any case, your code worked perfectly. On a side note, you don't happen to know of a resource outside of the obvious (as in posted on the F-Script site) that would be akin to a language reference do you? I've consulted the F-Script documentation and find it to be quite weak. My experience is primarily in PHP and I can attest to the fact that they have excellent documentation, by and large because they have every function mapped out in detail. Usually, I can pretty much work through any problem by consulting that. Unfortunately, I'm finding F-Script difficult to learn because 1) I don't know Objective-C and 2) because the documentation seems to be incomplete to me. Not that it's relevant, but I'm the type of person where I don't find tutorials to be all that helpful. I would much rather just look at each element and figure out how it works and worry about putting it together myself... In any case, thanks again for the advice. |
|||
|
|
Apprentice |
Well, it is. But then the "@" in the F-Script code (before the string) turns it into an array (see "message patterns" in the F-Script docs for more on this). Just use the following code instead: TOTAL := element valueForKeyPath:'parent.parent.parent.parent.parent.parent.reportData.objects.@sum.durationSeconds'.
F-Script just adds a little interpreted layer on top of Cocoa, as well as a few classes and methods. It only documents these added bits. You can refer to the standard Cocoa documentation for exhaustive descriptions of the objects provided by Cocoa. In particular, see the Cocoa Frameworks Reference Library at http://developer.apple.com/referencelibrary/API_Fundame.../Cocoa-api-date.html Philippe |
|||
|
|
Pro |
Philippe,
Thanks for the pointers. Like I said, I was pushing it to even get to where I got to so the whole message patterns section was a bit lost on me. I'm sure if I went over it like 20 times it might start to make sense... |
|||
|
|
Marketcircle Team |
Just a note. If you have an array of one object or if you have an array with many objects and you just want the last one... you can use the method lastObject.
----------------- result := (TOTAL/360) ceiling) * 0.1. result lastObject. ----------------- |
|||
|
|
Pro |
Oscar,
Thanks for the tip! I'm sure it will come in helpful one of these days... |
|||
|
|
Pro |
OK, so I'm still working on figuring this out, but I have a little problem. I'm using the aforementioned code (which should round to the tenth of an hour) but for .6 and .7 of an hour I get .6000000001 and .7000000001 respectively. Any assistance would be greatly appreciated!
|
|||
|
|
Pro |
I thought I would post a follow-up to my own question regarding rounding and decimal places. Although there isn't any documentation on using the custom number formatter (at least that I can tell), the easiest way to maintain a set number of decimal places is to simply select "Custom Number" and put in something like 0.0 in the "Format" box.
In fact, this is pretty intuitive, but given that my only real programming experience is in PHP, I had expected it to be something more like m:d:Y or something. I guess I was just over-complicating it, but I figured I would post my finding here for others (and for myself, in case I forget in the future). So, problem solved! That said, it still does look like there might be some slight math error in the report engine somewhere given that my previous strategy didn't work. Just a note... |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

