Selecting a specified amount of chars form a field

Use this board to ask questions or have discussions with other Genie users.
Post Reply
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Selecting a specified amount of chars form a field

Post by Wayne C. »

I'm trying to retrieve and display images on a screen in Genie. I'm already doing this on one screen using the following instruction.
script: '/profoundui/userdata/images/ttg/trailers/' + get('D_2_9') +'-d' + '.jpg'

This works because Im using the entire value of D_2_9 . I have another file to display images. I have groups of items (t-shirts) that have the exact same part # plus an additional suffix (t-shirt size). an example below.
XXXXXXXXX - S
XXXXXXXXX - XS
XXXXXXXXX - LG
XXXXXXXXX - XLG
The image for these 4 part #s are the same. We don't want to store 4 duplicate images. Is there a way to modify a script similar to the one above to only use the first 9 characters of this part # to retrieve an image?

Thanks in advance.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Selecting a specified amount of chars form a field

Post by Scott Klement »

The code is JavaScript, so you can code just about anything you can imagine...

Maybe do something like this? (assuming the XXXXXXXXX is always exactly 9 characters long)

Code: Select all

script: '/profoundui/userdata/images/ttg/trailers/' + get('D_2_9').substring(0,9) +'-d.jpg'
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Re: Selecting a specified amount of chars form a field

Post by Wayne C. »

Thanks Scott for your help. That worked great. It's a great addition to my limited javascript toolbox. However, turns out that the manufacturer's code won't always be 9 so we are going to have to rethink this. We may have to store duplicate images to keep things consistent with all the manufacturers we deal with.

Thanks again!
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Selecting a specified amount of chars form a field

Post by Scott Klement »

Another way to deal with it (slightly more complicated) is to search for the dash. Since all of your examples have "XXXXXX - YYY", there's always a dash after the number and before the size. So you could write code that searches for the dash and strips everything after it. Then the length of the XXXXX wouldn't matter.

Would that be of interest to you?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Selecting a specified amount of chars form a field

Post by Scott Klement »

Maybe even easier... just take everything before the first blank in the string

Code: Select all

script: '/profoundui/userdata/images/ttg/trailers/' + get('D_2_9').split(" ", 1) +'-d.jpg'
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest