Go Back   Printable User Community > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 30th, 2009, 11:54 PM
jbq jbq is offline
Forum n00b
 
Join Date: Sep 2008
Location: PHOENIX
Posts: 3
Default rule to convert negative dollars to use of parentheses

is there a way to write a rule that will add parentheses to financial data instead of the (-)negative? I know excel has the formula, but it is lost in .csv file

I see the Negative as Red rule, but that's not what they want. Wondering if anyone has already figured this out. any help is appreciated. Thanks
Reply With Quote
  #2  
Old November 2nd, 2009, 06:45 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 200
Default Re: rule to convert negative dollars to use of parentheses

Assuming your data includes the minus sign (-) at the beginning of negative values, would the following work?
Code:
return (Field("Amount").search(/-/)==0) ? "(" + Field("Amount").replace("-","") + ")" : Field("Amount");
__________________
Eric Smith
Prepress Guru
Classic Graphics
FP 6.0P1f, MAC OSX 10.5.7, Acrobat 9.1.3
Reply With Quote
  #3  
Old November 2nd, 2009, 02:28 PM
jbq jbq is offline
Forum n00b
 
Join Date: Sep 2008
Location: PHOENIX
Posts: 3
Default Re: rule to convert negative dollars to use of parentheses

Eureka!! You are the Guru! It worked great.
I got it to work, but I have several FIELDS to apply the rule to. I would like to have one rule ["to rule them all..."] that contains the definition for 12 fields ... do I need to create one rule for each FIELD, or do you have more magic to share. Thanks so much.
jbq
Reply With Quote
  #4  
Old November 3rd, 2009, 06:53 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 200
Default Re: rule to convert negative dollars to use of parentheses

You can either create a separate rule for each field (duplicate rule and update field info) or create a FOR loop to cycle through all fields in one rule (may have to create an array from all the data first). If you choose the latter, the "rule creator" would need to know how the result needs to be formatted first (space/tab/line break between results?).
__________________
Eric Smith
Prepress Guru
Classic Graphics
FP 6.0P1f, MAC OSX 10.5.7, Acrobat 9.1.3
Reply With Quote
Reply

Tags
rules

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:48 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
(c) 2008, Printable Technologies™, Inc.