Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 22nd, 2009, 10:35 AM
gandalf98 gandalf98 is offline
Junior Community Member
 
Join Date: Jul 2009
Location: Indianapolis
Posts: 20
Default indexOf Array

Hello all,

Need help with finding the index of an array element. I've created an array and called it CpnArray. When I attempt the following:

CpnArray.indexOf(CpnVrsn)

FusionPro tells me that CpnArray.indexOf is not a function.

I don't want to set up an external file and look up the record... That is going to eat up too much memory and time for this job.

Can I not look up the index of an element in an array? That seems way to simple of a Javascript concept to not be implemented.

Please help!
Reply With Quote
  #2  
Old September 23rd, 2009, 07:41 AM
tobarstep tobarstep is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Florida
Posts: 71
Default Re: indexOf Array

Quote:
Originally Posted by gandalf98 View Post
Hello all,

Need help with finding the index of an array element. I've created an array and called it CpnArray. When I attempt the following:

CpnArray.indexOf(CpnVrsn)

FusionPro tells me that CpnArray.indexOf is not a function.

I don't want to set up an external file and look up the record... That is going to eat up too much memory and time for this job.

Can I not look up the index of an element in an array? That seems way to simple of a Javascript concept to not be implemented.

Please help!
indexOf is a method of the String object and returns the starting position of a search string within another string. Arrays are not really searchable in that respect. What are you trying to accomplish with this array?
__________________
FusionPro VDP 9.3.12 Desktop/Server
Windows 7 Enterprise / Windows Server 2008 r2
Acrobat X
Reply With Quote
  #3  
Old September 23rd, 2009, 07:48 AM
gandalf98 gandalf98 is offline
Junior Community Member
 
Join Date: Jul 2009
Location: Indianapolis
Posts: 20
Default Re: indexOf Array

I see. I was attempting to use an array of Letters that correspond to page numbers in a PDF file for variable coupons:


var CpnArray = [ "A", "B", "C", "D", etc. ];

when my data file came as version B, I wanted to look up the index of letter B, which would tell me to place page 2 of my coupon file.

if I were to declare the variable as a string ("ABCDEFG"), I then could use indexOf?

Thanks for your help... I only know enough to be dangerous.
Reply With Quote
  #4  
Old September 23rd, 2009, 08:04 AM
tobarstep tobarstep is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Florida
Posts: 71
Default Re: indexOf Array

A simple string could work quite well for that then.
Code:
var myTest = "ABCDE";
return myTest.indexOf("B")+1;
You'll need the +1 at the end because everything is 0 based.
__________________
FusionPro VDP 9.3.12 Desktop/Server
Windows 7 Enterprise / Windows Server 2008 r2
Acrobat X
Reply With Quote
  #5  
Old September 23rd, 2009, 08:09 AM
gandalf98 gandalf98 is offline
Junior Community Member
 
Join Date: Jul 2009
Location: Indianapolis
Posts: 20
Default Re: indexOf Array

Already made the switch and thanks for the reminder on the "0" basis of javascript. Works great!
Reply With Quote
Old September 23rd, 2009, 09:53 AM
Dan Korn
This message has been deleted by Dan Korn. Reason: Never mind, I didn't see the follow-ups.
Reply

Tags
array, indexof

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 09:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.