Topic Options
#56766 - 02/18/19 05:15 PM Wild Card Variable Imaging
Joseph.Dimaco Offline
OL Newbie

Registered: 02/18/19
Posts: 5
Loc: Carrollton, TX
Good afternoon PSM experts!

A little background on what we're doing. We're using a API to pull Street View images from Google, then merging these images with the data list in PSM.

The issue I'm running into is each image is uniquely named and the only way I've been about to trigger the correct image is with the code below.

IF([SORTPOSITION]="1" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\1.jpg"), "C:\Users\Desktop\Images\2_Print\1.jpg","C:\Users\Desktop\Images\Generic.jpg")

I have to write a line of code like this for every single image and corresponding record number. So [SORTPOSITION] could range from 1 to 10,000 and the image could range from 1 to 10,000".jpg"

Is there anyway I can use a "wild card" to match the record with the correct image instead of forcing the match like I am above?

Top
#56767 - 02/18/19 05:26 PM Re: Wild Card Variable Imaging [Re: Joseph.Dimaco]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 435
Loc: Québec, Canada
Have you tried this?:

Code:
IF([SORTPOSITION]="1" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg"), "C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg","C:\Users\Desktop\Images\Generic.jpg")


Edited by Jean-Cédric (02/18/19 05:31 PM)

Top
#56768 - 02/18/19 05:44 PM Re: Wild Card Variable Imaging [Re: Jean-Cédric]
Joseph.Dimaco Offline
OL Newbie

Registered: 02/18/19
Posts: 5
Loc: Carrollton, TX
I have not, I will give that a try.

What is &[SORTPOSITION]& looking for? Is it searching for the value of "1" from the beginning of the line of code?

Top
#56769 - 02/18/19 05:59 PM Re: Wild Card Variable Imaging [Re: Joseph.Dimaco]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 435
Loc: Québec, Canada
Well I thought that [SORTPOSITION] could be relied on for the name of the file...but if you want to use the record number, use this instead:

Code:
IF([SORTPOSITION]="1" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&STR(RECORD_NR())&".jpg"), "C:\Users\Desktop\Images\2_Print\"&STR(RECORD_NR())&".jpg","C:\Users\Desktop\Images\Generic.jpg")


RECORD_NR() will return the current record number.
STR() will convert RECORD_NR() to a string.

and the "&" is used to concatenate 2 strings.

Top
#56770 - 02/19/19 09:24 AM Re: Wild Card Variable Imaging [Re: Joseph.Dimaco]
Joseph.Dimaco Offline
OL Newbie

Registered: 02/18/19
Posts: 5
Loc: Carrollton, TX
I apologize for the confusion, yes [SORTPOSITION] can be relied on for the name of the file.

Will I need to have a string of code for every value of [SORTPOSITION]? Like the example below.


IF([SORTPOSITION]="1" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg"),"C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg",
IF([SORTPOSITION]="2" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg"),"C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg",
IF([SORTPOSITION]="3" AND FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg"), "C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg","C:\Users\Desktop\Images\Generic.jpg")))

Top
#56771 - 02/19/19 10:31 AM Re: Wild Card Variable Imaging [Re: Joseph.Dimaco]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 435
Loc: Québec, Canada
Now if [SORTPOSITION] can be relied on for the name of the file, then you should only need 1 string of code:

Code:
IF(FILE_EXISTS("C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg"),"C:\Users\Desktop\Images\2_Print\"&[SORTPOSITION]&".jpg","C:\Users\Desktop\Images\2_Print\generic.jpg")

Top
#56773 - 02/19/19 12:05 PM Re: Wild Card Variable Imaging [Re: Jean-Cédric]
Joseph.Dimaco Offline
OL Newbie

Registered: 02/18/19
Posts: 5
Loc: Carrollton, TX
shocked
This worked, you just saved me so much time!
Thank you! Next time I'm in Québec I own you a beer!

Top
#56774 - 02/19/19 12:11 PM Re: Wild Card Variable Imaging [Re: Joseph.Dimaco]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 435
Loc: Québec, Canada

Top