These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Pull letters out of text fields and calculate......

jenawyn
Registered: Apr 1 2011
Posts: 12

Hi,
 
I have text fields numbered Text.900 thru to Text.980. I am trying to adapt the following formula (without Luck) to pull out the letters MG,SW,MI,CW out of the text fields and sum them.
 
The user would be entering in the text fields MI-20000-455 or CW-45000555-99 0r 99-0000000-12, variation of numerals, but the one constant is the MI CW MG SW
So I need to count the instances of them if possible?
 
var sum = 0;
 
// Loop through the input fields
for (var i = .900; i < .980; i++)
{
if (getField("Txt" + i).valueAsString === "MI")
{
var num = getField("Text." + i).value;
sum += Number(num);
}
// Set this field value equal to the sum
event.value = sum;}
   
Any ideas how to do this....
 
Cheers Stephen
  
acrobat 10.01 windows

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You will have to use the RegExp to split the value of the fields so you can extract the numeric values.

George Kaiser

jenawyn
Registered: Apr 1 2011
Posts: 12
Hi George,

Could you at least point me in a direction I have had a look at Regexp in search but no one seems to have the same sort of question I have posed?

I'm no expert as you can gather and amateur at best

Cheers
Stephen
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
See Text matching with regular expressions by Thom Parker for starters.

George Kaiser

jenawyn
Registered: Apr 1 2011
Posts: 12
Well cant make sense of it, so I give up.

Thanks anyway...

Closed.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Feel free to contact me personally. I can create for you the script that will do it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

jenawyn
Registered: Apr 1 2011
Posts: 12
Thanks for the offer try67...................but if it cant be put on here I'm not interested.

This Acrobat forum is no where near as helpful as the ones dealing with excel, word, access which I'm members of and people actually dare I say would post code and help each other so everyone learns.

At least you could see what code does and maybe adjust it to suit your needs etc....

On this forum a substantial amount of questions are answered with questions or a go and read this and your still none the wiser, after reading a fair amount of posts here.

I appear to be not the only one who has come to the same conclusion.

Knowledge is power I've heard, & boy some of you sure show it.I've been most disappointed with this forum.

Just my 2 cents worth since I've been a member here.


Regards
Stephen
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I disagree. Myself and many others post huge amounts of code here.
Sometimes a better approach is indeed to direct the poster to the reference files or the forum's search engine or to articles that explain what code they can use to solve their problems, since most questions can be answered with the information there.
Remember that everyone that posts here is a user, just like yourself, and does so voluntarily and in their own free time...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com