Jump to content

ehigginbotham

Registered Users - Approved
  • Posts

    34
  • Joined

Posts posted by ehigginbotham

  1. I need to round off a number.

    example, my number is 41.25

    I want to multiply it by 1.25, and then round it always up to the next 5 increment.

     

    so

    41.25 x 1.25 = 51.56

    I need that number to come out to be 55.

    I have figured out how to round it, it just doesn't always round up.

    here is the final rule

    var x = parseInt(Rule("g1"))

    var mult = (x*1.25)

     

    var z = Math.round(mult / 5) *5

    var y = parseInt(z)

    return y;

     

     

    here is rule G1

    var x = parseFloat(Field("AMT"))

    var z = Math.round(x)

    var y = parseInt(z)

    return y;

     

    any ideas to make it always round up to the nearest 5 increment in whole numbers?

  2. I have the following rule which works great until the return is not formatted correctly.

    CustTypeSplit=Field("LASTGIFT").split(".")

    Number=CustTypeSplit[0]

    decimal=CustTypeSplit[1]

    var nocomma= Field("LASTGIFT").replace(/\,/g, "");

    var G2=nocomma*1.5

    var formattedG2=FormatNumber("#,###.##", G2)

    if (Number <=19.99)

    return 40;

    else return formattedG2;

     

    basically, if the number is 19.99 or less, I want it to return 40. if its greater than that I want it to return the number multiplied by 1.5. which works until its a number like 35, which comes out to 52.5. I would like it to return 52.50. I know its something simple in the formatting of it, but I don't know how to do it. Any help would be appreciated.

  3. this seems really dumb, but I can't get this to work now that some of the data has a decimal, and some does not. basically all I need to do this time is have the return be either a whole dolloar... 25 when the data is 25.00, or when the data is $25. also need to be 2.05 if the data is 2.05. or 2.10 if the data is 2.10. the rule above works for all of these instances except for the one that's 2.10, because the data comes in as 2.1 and that's what it sees. I know this should be simple, but its driving me nuts at the moment. any help would be appreciated.

    thanks

  4. var giftAmount = Field("LASTGIFT").replace(/\$/g, "");

    CustTypeSplit=giftAmount.split(".")

    Number=CustTypeSplit[0]

    decimal=CustTypeSplit[1]

    if (giftAmount <= 25)

    return '25.00';

    else

    if (decimal ==.00)

    return Number;

    else return Number +"."+decimal;

     

     

    this wound up working... thank you very much. This forum rocks.

  5. ok, so here is a synopsis of what I'm trying to do.

    I have a field called last gift, ($xx.xx) is how it is formatted. what I need to do is to make it $25 if its less than $25.00.

    I also need it not to show the .00 if they are .00, but if it is something like $25.40 to make it show that.

    here is where I am and I can't get it to work, it always returns $25 no matter the value.

     

    var1=Trim(Left(Field("LASTGIFT"),"1"))

     

    CustTypeSplit=var1.split(".")

    Number=CustTypeSplit[0]

    decimal=CustTypeSplit[1]

     

    if (Number<='25')

    return "25";

    else

    if (decimal ==.00)

    return Number;

    else return Number +"."+decimal;

     

    any help would be greatly appreciated.

  6. I am trying to split up a field into the first initials of each word if the string of text is greater than 31 characters.

     

    example

    if the field contains less than 31 characters, return the filed. If it contains more than 31 characters return the first letter of each word in the field.

     

    I tried to do a basic split on the " " and I gave it up to 6 possible variable splits. Then I tried to trim the first letter off of each variable split. It works when there are 6 words to split, but it returns an error when there are fewer. There is probably a much easier way to do this, but here is the code I have so far. (I haven't even gotten to checking the field for the number of characters yet, so it there is an easy way to do that, can you throw that in also.

     

    CustTypeSplit=Field("NAME1").split(" ")

    first=CustTypeSplit[0]

    middle=CustTypeSplit[1]

    last=CustTypeSplit[2]

    last2=CustTypeSplit[3]

    last3=CustTypeSplit[4]

    last4=CustTypeSplit[5]

     

    if (first == "")

    var1=""

    else

    var1=Trim(Left(first, "1"))

    if (middle == "")

    var2=""

    else

    var2=Trim(Left(middle, "1"))

    if (last == "")

    var3=""

    else

    var3=Trim(Left(last, "1"));

    if (last2 == "")

    var4=""

    else

    var4=Trim(Left(last2, "1"));

    if (last3 == "")

    var5=""

    else

    var5=Trim(Left(last3, "1"));

    if (last4 == "")

    var6=""

    else

    var6=Trim(Left(last4, "1"));

     

    if (Len(Field("NAME1")>=31))

    return var1 +" "+ var2 + " " + var3 + " " + var4 + " " + var5 +" "+var6;

    else return Field("NAME1");

     

    thanks in advance

    Eric

  7. I have two data fields that have large numbers in them. I need to subtract one number from the other. they have two decimal places. This sounds simple enough, but I can't get it to work without FP doing some wierd formatting on the numbers, that gives me 17.00 instead of 16855.36.

    its like it is rounding up the first two numbers.

    Here is the rule as I have it currently.

     

    var account = StringToNumber(Field("ACCOUNT-ENDING"))

    var company = StringToNumber(Field("COMPANY-ENDING"))

    var total = account - company

    return FormatNumber("#####.##",total)

     

    // the numbers in the data are

    //ACCOUNT-ENDING = 66,442.44

    //COMPANY-ENDING = 49,587.08

    //the result of this function is 17.00

     

    any idea what I am doing wrong?

  8. A little different spin on it.

    I have a file that has about 26000 records in it that go onto three different letters. The data has a field that identifies which letter that it is supposed to apply to. There are about 79 different record types, which are identified by that field. Is there a way in FP to export the files by that field? Our fulfillment department needs them seperated by that field. We have sorted them into order in our mailing software. It just seems very redundent to have to export 79 files out of the mailing software, and then link to 79 different files, and compile them all seperately.

     

    any ideas?

  9. I need to write a rule that will name my output file with a static name followed by the date. I would like to add a time stamp to the end of the date so that if I had to run two of these jobs in the same day, the files would not overwrite. I do not see any code for the timestamp. Anyone know what it is?

     

     

    my date rule

    //date rule

    var todaysdate = Today();

    return (FormatDate(todaysdate, "mmm dd, y"));

     

     

    my rule so far is on the OnNewoutputfile callback rule.

     

    //NewOutputFileName rule

    FusionPro.Composition.outputFileName = "MKT-271/MKT-271" +"_"+ Rule("r_date") + ".pdf";

     

     

    thanks

  10. Now that this rule is working, I need to use it in conjunction with a rule that will make the total page count of a book divisable by 4. Here is the rule I have so far. Any suggestions.

     

    //Letter Page

    if ((Field("ZIP")) == "")

    {

    FusionPro.Composition.SetBodyPageUsage("Directory file",false);

    }else{

    FusionPro.Composition.SetBodyPageUsage("Directory file",true);

    }

     

    if (Field("Page 1 y or n") == "y")

    {

    FusionPro.Composition.SetBodyPageUsage("70",true);

    }else{

    FusionPro.Composition.SetBodyPageUsage("70",false);

    }

    if (Field("Page 2 y or n") == "y")

    {

    FusionPro.Composition.SetBodyPageUsage("71",true);

    }else{

    FusionPro.Composition.SetBodyPageUsage("71",false);

    }

     

    if (Field("Page 3 y or n") == "y")

    {

    FusionPro.Composition.SetBodyPageUsage("72",true);

    }else{

    FusionPro.Composition.SetBodyPageUsage("72",false);

    }

     

    // place each field into an array

    // then count the number of pages in each pdf and add them together

    //if there are any static pages in the booklet

    // adjust the starting number of the PAGECount here.

    // since we have no static pages in this booklet, keep the PAGECount at 0

     

    var PAGECount=86;

    var PicPages=4;

    PAGEArray = [ Field("ZIP"),Field("Page 1 y or n"),Field("Page 2 y or n"),Field("Page 3 y or n") ]

     

    for (i = 0 ; i < PAGEArray.length ; i++)

    {

    if (PAGEArray != "")

    {

    var Pic = new FusionProResource(PAGEArray, "graphic", "true");

    PicPages = Pic.countPages;

    PAGECount+=PicPages;

    }

     

    }

     

    //divide pagecount + 10 by 4

    //if remainder is 1, you will need all 3 blank pages

    //if remainder is 2, you will need 2 blank pages

    //if remainder is 3, you will need 1 blank page

    if (PAGECount % 4 == 1)

    {

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 1", "true");

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 2", "true");

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 3", "true");

    }

     

    else if (PAGECount % 4 == 2)

    {

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 1", "true");

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 2", "true");

    }

     

    else if (PAGECount % 4 == 3)

    {

    FusionPro.Composition.SetBodyPageUsage("Intentional Blank 1", "true");

    }

  11. I had figured out the / instead of \ thing through luck. lol I am actually using this rule for a template in marcom central, do you know if the 3rd option will work if the paths to the images are on the web? I know this is actually a question for that forum, but this rule was so similar I started here.

     

    thanks for your help

×
×
  • Create New...