[JS][CS5] rounding decimals in swatch values

Hello again,
I recently made this script to round decimals in the swatch values if there were any. I'm pretty new to JS so this probably isn't the prettiest code so I was wondering if someone had a better way of doing it.  This works, but sometimes it takes a while and I'm pretty sure it is looking at the [paper], [black], and other swatches that can't be changed.  That is why I made it skip the errors during the script...
function round(color) {
    try { color.space = ColorSpace.cmyk;
    var vals = color.colorValue;
    for (var j = vals.length - 1; j >= 0; j--) {
        vals[j] = Math.round(vals[j]);
    color.colorValue = vals;
} catch (err) {}
if (app.documents.length > 0) {
        var target = app.documents[0];
    } else {
        var target = app;
var myColors = target.colors.everyItem().getElements();
for (var j = myColors.length - 1; j >= 0; j--) {
    round(myColors[j]);
alert("Swatches Rounded");
Any help is appreciated.

Same bug in ESTK 3 / CS4.
The data browser definitely has a problem in displaying object properties whose name starts with a (recurring) digit. The issue is not related to property names that could contain a space character —which is not forbidden! Curiously, it seems that the bug only occurs with digits greater than 1.
Compare:
var obj = {
     "0a": null,
     "00b": null,
     "1a": null,
     "11b": null
// The data browser properly displays all obj properties
and:
var obj = {
     "2a": null,
     "22b": null,
     "5a": null,
     "55b": null
// The data browser only displays obj['5a'] and obj['5b']!
Note that this is not an internal ExtendScript bug. In all cases the object is properly set, the for...in loop works fine and obj.__count__ returns the correct number of enumerable properties.
Conclusion: ESTK sucks!
@+
Marc

Similar Messages

  • Rounding off net weight value.

    Hi experts,
    I want to round off the quantity value to the next integer value.
    I am using the FM 'J_1I6_ROUND_TO_NEAREST_AMT' as follows...
    call function 'J_1I6_ROUND_TO_NEAREST_AMT'
    exporting
       i_amount = gross_weight
       i_amount1 = net_weight
    importing
       e_amount = gross_weight
       e_amount1 = net_weight.
    i want to round off the gross weight and net weight values.
    In Global definitions, these are given as of type VEKP-BRGEW. The field BRGEW is of datatype QUAN (length - 15 and decimal -3 )
    But when i tried executing i am getting dump .... saying
    "The function module interface allows you to specify only
    fields of a particular type under "I_AMOUNT".
    The field "GROSS_WEIGHT" specified here is a different field type"
    Please help me solve this and please let me know how to round off these fields.
    Regards
    Ammu

    Hi,
    the both fm parameters you fill have a currency data element of length 13, while you pass a quantity data element of length 15.
    You can't use this fm for your fields.
    Regards,
    Klaus

  • Mismatched swatch values

    We are using CS4. As part of our production process we are using a program called FlightCheck to preflight files. We just upgraded to a new version of this application and it is indicating that there are conflicting values in colors used in our documents. This usually means that a color specified in InDesign is different than a color in an eps file placed in the InDesign file. Upon checking the graphics it appears that the CMYK values of the colors are different in InDesign. We are using a set of swatches we created and saved out for all to share so everyone is using the same colors. When we load these swatches in Illustrator the CMYK numbers are correct, however when we load them into InDesign they are changed slightly. For instance a color defined as C=100, M=40, Y=20, K=0 in Illustrator appears in InDesign as C=100, M=39.9, Y=20.0001, K=0. I checked that our color settings are synchronized for the Creative Suite so why would this be happening? Has anyone seen this behavior before? Thanks in advance for any help.

    They are not converting spot colors and the graphics don't have embedded
    profiles. What's strange is the old version of FlightCheck didn't flag it,
    but the new version does.
    I'm like you, I'd like to know where it is coming from. I saved out the
    swatches from Illustrator with just a blank document open and loaded them
    into a blank InDesign file and the values changed just doing that. There
    were no imported graphics involved. If I fixed the values in InDesign and
    saved the swatches again, then imported them back into InDesign they were
    fine. Strange...
    Thanks!
    Beth Phillips
    From: Peter Spier <[email protected]>
    Reply-To: <[email protected]>
    Date: Thu, 05 Aug 2010 14:04:57 -0600
    To: Beth Phillips <[email protected]>
    Subject: Mismatched swatch values
    This is going to be more a cosmetic problem in the application than a problem
    on press. You won't be able to detect a difference of .1%, let alone .001%,
    but it would be nice to know where it's coming from.
    Are you converting spot colors? Do the imported files have embedded profiles,
    and if so do they match the ID working space?
    >

  • SQL for rounding to the nearest value

    Hi All,
    My Oracle DB version is 10g Release2 and also 11gR1
    I have data like below, I need to write a SQL for the below requirement.
    ID   RANGE_LOW                RANGE_HIGH
    1      50                    55             
    2      55                    60
    3      60                    63 
    4      63                    77 
    5      77                    84   The requirement is like I need to check a value between the above range low and high then round it to the nearest value.
    Say, for example if I have 68 then the value is rounded to 63 else if 74 then 77 else if its in the middle of two values (70) then rounded to the highest value, here its 77.
    Please advice.

    Ashu_Neo wrote:
    hi Purvesh,
    I think , you didn't check it properly with requirement of posting. Your query needs to be changed a bit. Please verify againYes, I probably missed or overlooked the last line.
    Here is the updated solution then:
    with data as
      select 1 id, 50 low, 55 high from dual union all
      select 2, 55, 60 from dual union all
      select 3, 60, 63 from dual union all
      select 4, 63, 77 from dual union all
      select 5, 77, 84 from dual 
    chk_val as
      select &val val from dual
    select id, low, high,
           val input_value,
           case
            when val < (low + high)/2
              then low
            else
              high
           end round_value
      from data, chk_val
    where val between low and high;
    ID                     LOW                    HIGH                   INPUT_VALUE            ROUND_VALUE           
    4                      63                     77                     70                     77

  • Rounding of Net Book Value or Depriciation

    Dear All,
                    How Can we round the Net Book Value and / Or Depriciation.
    Thanks & Regards,
    Mahendra Gupta

    Yes, we can
    T CODE: OAYO - Select each Dep. area and do it as per your client req.
    Normally, max no follows "Arithmetic rounding:
    Tnaks

  • No rounding decimals

    Hi,
    i am using currency(ZCURR) field.
    which is upto 2 decimals.
    after calculation in currency(ZCURR) field data is comming wotih rounding.
    also i tried with PACKED decimals upto 2
    still it rounding off as i wnat actual value upto 2 decimals
    Ex: ZCURR type VABAK-netwr.
    ZCURR = '2331.437'.
    write : ZCURR
    result : 2331.44  but i want at output "2331.43".
    please help.

    Hi,
    Try below
    SPRO->Sap customizing guide->sap netweaver->general setting->currencies->set decimal places for currencies
    Surendra Jain

  • Can Photoshop no longer handle decimals in feathering values?

    Hi,
    I've always appreciated the sensitivity of the feathering in Photoshop, where there was actually a difference between 0.3 and 0.4 px feathering (on the selection lasso, for instance).
    However, ever since upgrading to CS5, I've noticed that Photoshop doesn't seem to like decimal feathering. Anything between 0 and 0.4 looks exactly the same, and everything between 0.5 and 1.4 looks the same as well. In other words, Photoshop seems to be rounding it out to the nearest full pixel.
    There are situations where I litterally need 0.5 px feathering, but can't get it.
    Is this a bug, or am I doing it wrong?
    Note : Been using Photoshop since 1997, this is the first time I've encountered this problem.

    I can confirm what you're reporting.  I hadn't noticed the difference myself as I rarely use decimal feathering values, but I just tested...
    What I did was this:
    1.  Make a rectangular selection with 0.4 pixels feathering.  Copy / Paste as a new layer.
    2.  Repeat step one on the original at 0.6 pixels, and 1 pixels.
    The 0.4 pixel copy has a perfectly hard edge (i.e., there really was no feathering at all).
    The 0.6 pixel feathering and 1 pixel feathering copies are identical.
    Same results in Photoshop CS4.  I haven't had time to test CS3 or earlier yet.
    This surprises me a little, as I believe Chris Cox (of Adobe) worked to actually INCREASE the resolution of many of the functions of Photoshop CS5 - for example you can now specify the rotation of a free transform to the hundredth of a degree instead of just a tenth.
    -Noel

  • How can I make a row of cells containing 3-digit decimals, who's values resulted from calculations within the spreadsheet, appear as durations of minutes and seconds?

    Row 6 in this spreadsheet is the result of Row 2/Row 3 as evidenced by the formula listed while Cell Y6 selected. How can I make the values in this row appear as durations of minutes and seconds rather than 3-digit decimals? For example, rather than appearing as 9.84 I would like the value of Cell Y6 to appear as 9:50 or 9min 50sec. (obviously .84x60seconds 50 seconds). I tried changing the cell formats from "number" to "duration," but no change is made. Using the "duration" format does however work if I am manually entering the decimal value into the cell rather than allowing it to result from another caluclation within the spreadsheet. Is there a solution to this within Numbers '09? You can see why I would want the "pace" displayed in minutes and seconds. Thanks in advance!
    Ryan

    Hi Ryan,
    You wrote:
    "The problem is that my "Distance" is a row of automatically generated values resulting from ((Row1/60)*Row 6). Changing the format of Row 1 to minutes causes row two to be expressed as a duration, which obviously it shouldn't because it is a distance. The spreadsheet has to be designed so that all I have to manually input on each entry are Row 1 Values (Time) and Row 6 Values (Average Pace). The rest of the cells must be automatically poulated as a result of formulas."
    I'm assuming that where you say "Row 1" in this you mean "Row 2", which is labeled "Time" in the example in the OP.
    In the original post, you presented a formula from cell Y6. Replacing the Header labels in that formula's cell reference with the Addresses of the referenced cells, the formula was:
    Y6: =Y2/Y3
    In this post, you are saying that Y6 contains entered data: "...all I have to manually input on each entry are Row 1 Values (Time) and Row 6 Values (Average Pace).
    Which is correct?
    Regards,
    Barry

  • Too many decimals in Average value

    Hi
    I am using Report Builder and the wizard do design a table which i deploy as a .jsp page.
    For some columns in the table I select to display the average values. Some of the values looks fine with one decimal as i want, but some values is displayed with a lot of decimals (about 10) as 164,346666666666666666. I have tried to change the length but without effect. Are there any possibility to decide the number of digits to be shown in the report . Or is i it a bug in Report Builder.

    Go to Property Inspector of the field and choose the right "Format Mask".

  • Rounding off Issue (Net Value not equal to Net Price * quantity)

    Dear Gurus,
    Here is an interesting issue.The default calculation done in the pricing procedure is two decimal places.Now we consider a real scneario,consider the net value of 324 quantities of an item calculated is 36,049.86 .When it is divided by quantity  the resulting value of net price is 111.265 but the system shows 111.27 by rounding it off.
    Now here comes the problem,my client needs the rate to be shown on the order script to be two decimal places and the net value should be equal  quantity * net price.So if we apply this,
    324 * 111.27 = 36051.48
    But the net value calculated by the system is 36,049.86.So it can be consluded that:
    "Quantity * Net Price Shown is not Equal to Net Value calculated by the System"
    Need an urgent resolution,project is stuck on this
    Regards,
    Sam Ahmed
    Edited by: Lakshmipathi on Nov 3, 2011 12:14 PM
    Please dont add URGENT in subject or in your post

    Here is the pricing procedure,
    We start with the amount condition types
                                            Unit Price        Units Condition Value
    ZMRP     MRP                     1,700.00           10     PAC     55,080.00      
    ZTRP     Trade Price     1,445.00           10     PAC     46,818.00      
    ZDPR     Dist. Price     1,445.00           10     PAC     46,818.00         (GL)
    Using Trade Price we apply the product discount of 23%
    ZPRD     Product Discount     23.000-     %                    10,768.14-
    Then we send discount amount to the gl by using condition type ZDIS
    ZDIS      Discount Value     100.000-     %           10,768.14-      (GL)
    tHE RESULTING NET VALUE IS  36,049.86      as 46818.00 - 10,768.14
         Order Item value     111.27      1     PAC     36,049.86      
    And the Net Price is 111.27

  • Problem in Routine after rounding off the condition value

    Dear all,
          I have attached the routine for rounding off value for condition value for T.Code va02. Routine is working fine but the problem is after the execution of routine it goes in some standard program LV61AA55 where again the rounded value gets changed . Maximum points will be allocated ..
    Thanks anr Regards

    FORM FRM_KONDI_WERT_925.
    *{   INSERT         D01K911062                                        2
    data : wa_xkomv like xkomv,
            v_kwert like xkomv-kwert,
           W_INDEX  TYPE SY-TABIX.
    read table xkomv into wa_xkomv with key kschl = 'JIN6'.
    W_INDEX = SY-TABIX.
    v_kwert = 1 * wa_xkomv-kwert / 100.
      V_KWERT = WA_XKOMV-KWERT.
    read table xkomv with key kschl = 'JHSC'.
    CALL FUNCTION 'J_1I6_ROUND_TO_NEAREST_AMT'
       EXPORTING
         I_AMOUNT                 = v_kwert
       I_AMOUNT1                =
       I_AMOUNT2                =
       I_AMOUNT3                =
       I_AMOUNT4                =
       I_AMOUNT5                =
       I_EXADDTAX1_AMOUNT       =
       I_EXADDTAX2_AMOUNT       =
       I_EXADDTAX3_AMOUNT       =
      IMPORTING
        E_AMOUNT                 = v_kwert
       E_AMOUNT1                =
       E_AMOUNT2                =
       E_AMOUNT3                =
       E_AMOUNT4                =
       E_AMOUNT5                =
       E_EXADDTAX1_AMOUNT       =
       E_EXADDTAX2_AMOUNT       =
       E_EXADDTAX3_AMOUNT       =
    xkomv-kwert = v_kwert.
    xkwert = v_kwert.
    modify xkomv INDEX W_INDEX transporting kwert.
    *}   INSERT
    ENDFORM.

  • Rounding off to nearest value with formatNumber

    Can I use the formatNumber tag to round my numeric value to the nearest value?
    Like if it's 15.7 I would like to display 16
    And if it's 15.2, I would like to display 15
    I could successfully truncate by giving a patteren but Im not sure if I can round it off.
    Regards,
    Leena

    Yes you can - the following works on JSTL 1.1 / Tomcat 5.5 :
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <html>
    <head><title></title></head>
    <body>
    Test Auto Rounding of 16.8 :
    <fmt:formatNumber value="16.88" pattern="##"/>
    <br/><br/>
    Test Auto Rounding of 16.2 :
    <fmt:formatNumber value="16.22" pattern="##"/>
    </body>
    </html>Message was edited by:
    appy77

  • Rounding decimals

    Dear all,
    Is there any way to restrict the Signed data decimal to 2 places? We have decimal formatted in the BPC Excel front end. But this doesnt stop data from Input schedule restricted to 2 decimal places in fact table.
    Some users wrongly enter data with more than two decimal places in input schedule. Although such data is rounded off in the excel front end view, it doesnt get rounded in the fact table. We have issue when we try to extract such data using custom SSIS. We have option to round off at the time of extraction using custom SSIS. But when we extract huge data records, there are some reconciliation differences due to rounding. So the BPC data and extracted data differs. Is it possible to round the data at face table level?

    Hi Lokesh,
    We also have the same requirement.  No decimal places required.  I had done the changes to include SIGNED_DATA_FORMAT to 13.0, and have rebuilt the indexes on the Consolidaiton Cube. However it still doesn't work as expected.
    When I run currency conversion, the coverted values still shows decimal places.
    Are we missing any step here?
    We are on BPC 10NW SP05.
    Please suggest.
    Regards,
    Rashmi

  • Rounding decimals using FM REUSE_ALV_HIERSEQ_LIST_DISPLAY

    Hi all.
    I am having no luck get values to round in FM REUSE_ALV_HIERSEQ_LIST_DISPLAY.  I have managed to get them to round in REUSE_ALV_GRID_DISPLAY by setting DECIMALS_OUT to a value of 0.
    Any help would be very much appreciated.
    Anthony

    Hi Anthony,
    <b>1</b>.
    If DECIMALS_OUT is working properly for REUSE_ALV_GRID_DISPLAY,it should work for REUSE_ALV_HIERSEQ_LIST_DISPLAY.Becoz there is no difference between two fieldcatalogs .
    <b>Thanks,
    Venkat.O</b>

  • Rounding Off to lower value!

    Dear Experts,
    Currently am calculating some values, and it returns me the results as such:
    If the calculated value is 6.85714, then by default the output value in my integer type variable is 7.
    Now, whenever the output results in 6.xxx, even if it is 6.9999 then i want it to round off to 6.
    How is it possible?
    Please advice!
    Regards,
    Sundar.

    Hi
    Handle it like this,,,
    CLEAR : l_f_kbetr4 , l_f_kbetr5 .
    l_f_kbetr4 =   l_F_kbetr1 - l_f_kbetr3 .
    CHECK      =   FRAC( l_f_kbetr4 ) .
    IF CHECK GE '0.50' .
      l_f_kbetr4  = CEIL( l_f_kbetr4 ) .
    ELSE .
      l_f_kbetr4  = FLOOR( l_f_kbetr4 ) .
    ENDIF.
    l_f_kbetr5        =   l_f_kbetr4 .
    Hope it helps.
    Praveen

Maybe you are looking for

  • I am no longer able to post application review in iTunes.

    What happened to the iTunes 10, that I no longer can leave any reviews about Apps and no longer can use Yes or No in the "This Feedback was helpful" section? Thanks.

  • Specify card type error in Bdocs

    Hi, We need to download customers from ECC to CRM , when executed , there is no error captured in SMQ2. But the BDocs are generated in  SMW01 and found  R1561 error with error u2018Specify a card typeu2019. Can anyone suggest what needs to be done to

  • Capturing with xdcam

    Hi, what setting do I use to capture from xdcam??? ( optical disk) Thanks for any insight you can provide! Leigh

  • Audio Manager will not save tracks

    Hi I am using PC Suite 6.70.22 with Windows XP SP1. PC is PIII 660MhZ with 168Mb RAM. Have set up connection to Nokia 6131 and is working fine. However when I tried to save tracks in Audio Manager (either to hard disk or to phone directly) I get one

  • HT4796 the migration assistant keeps getting interrupted

    Hi I'm a brand new Mac userer and I am trying to transfer my data  from the pc to my mac using the migration assistant however everytime I run the intallation it gets interrupted. I don't know what is interrrupting it. I've turned off all windows aut