1253 Views    -    26 Replies


Username Post: Determining File extension type on import        (Topic#215499)
Your continued generosity and support of FMForums is greatly appreciated.
MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-02-10 12:32 PM - Post#359634     - Post Rank:             


I need to determine the types of pic files a user is importing into our app.
We only allow "Insert Picture(Reference)" into our DB because we don't want to jam up the DB.
The reason being is that some people have been importing "peg", "PDF" files instead of valid "jpg or jpeg" files. When our china users try to access the style on their windows machine, because we do a refresh of all pics, we get the dreaded white screen of app freeze which needless to say frustrates them.
The current script statements that the other "developer" put in doesn't work because it references an empty container field."see code...'
I need to know this at the Insert Picture script so that I can kick them out if they have chosen the wrong type.

Code:

  04 Import Export04-0190 Import ArtArt Department Entry  Show Custom Dialog Title"IMPORT IMAGE & CREATOR FILE"Message"Import " Get (ScriptParameter) & " JPG and creator  file?"Buttons“OK”“Cancel”  If Get (LastMessageChoice) =  Exit Script [  ]  End If  Freeze Window  Set Error Capture On  #Check for Mac or PC  If [ Middle( Get (DesktopPath);2;1) = "U" or Middle( Get (DesktopPath);2;1) = "m" or Middle( Get (DesktopPath);2;1) = "M"  // Mac ]  Set Variable [ $filepathserver; Value:"filemac:/" ]  Set Variable [ $imagepathserver; Value:"imagemac:/" ]  End If  If [ Middle( Get (DesktopPath);2;1) = "C"  //  PC   ]  Set Variable [ $filepathserver; Value:"filewin://DEEPTHOUGHT/" ]  Set Variable [ $imagepathserver; Value:"imagewin://DEEPTHOUGHT/" ]  End If  #Set Variables and get script parameter  Set Error Capture [ On ]  Set Variable [ $section; Value:GetValue ( Get ( ScriptParameter ) ; 1 ) ]  Set Variable [ $StyleCode; Value:Style_Main::Style_ID_Style_Code ]  Set Variable [ $StyleSN; Value:Style_Main::Style_ID_Serial_Number ]  Set Variable [ $ProgramCode; Value:Style_Main::Style_ID_Program_Code ]  Set Variable [ $ProgramName; Value:Programs::Program_Name ]  Set Variable [ $ProgramNumber; Value:Style_Main::Style_ID_Program_SN ]  Set Variable [ $action; Value:"Import" ]  #BW Front JPG  If [ $section = "BW Front" ]  Show Custom Dialog [ Title: "IMPORT JPG"; Message: "Import " & Get (ScriptParameter) & " JPG."; Buttons: “OK” ]  Set Field [ Style_Main::Style_Graphic_3_Count_BW_Front; Style_Main::Style_Graphic_3_Count_BW_Front + 1 ]  Set Variable [ $version; Value:Style_Main::Style_Graphic_3_Count_BW_Front ]  Go to Field [ Style_Main::Style_Graphic_JPG_3_BW_Front ]  Insert Picture [  ]  [ Reference ]  Set Variable [ $filepathjpg; Value:$filepathserver & "MondettaEnterprise/Groups/ERP/Documents/Programs/"  & Style_Main::Style_ID_Program_SN & "/"  & Style_Main::Style_ID_Program_SN & "_Art_BW/"  & Style_Main::Style_ID_Style_Code & "_BW_Front_"  & Style_Main::Style_Graphic_3_Count_BW_Front  & "." & Case (  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 1; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 2; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 4 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 3; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 3 )) ) ]  #> Require File validation here to stop user from importing non JPEG files.  //  If [ Right ( Style_Main::Style_Graphic_JPG_3_BW_Front ; 3 ) ≠ "jpg" or Right ( Style_Main::Style_Graphic_JPG_3_BW_Front ;  3 ) ≠ "jpeg" ]  //  Show Custom Dialog [ Title: "INCORRECT FILE TYPE"; Message: "You can only use JPG's, please try again."; Buttons:  “OK” ]  //  Clear [ Style_Main::Style_Graphic_JPG_3_BW_Front ]  [ Select ]  //  Exit Script [  ]  //  End If  Set Variable [ $imagemacjpg; Value:$imagepathserver & "MondettaEnterprise/Groups/ERP/Documents/Programs/"  & Style_Main::Style_ID_Program_SN & "/"  & Style_Main::Style_ID_Program_SN & "_Art_BW/"  & Style_Main::Style_ID_Style_Code & "_BW_Front_"  & Style_Main::Style_Graphic_3_Count_BW_Front  & "." & Case (  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 1; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 2; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 4 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 3; 1 ) ; "."; Right  Set Variable [ $imagemacjpg; Value:$imagepathserver & "MondettaEnterprise/Groups/ERP/Documents/Programs/"  & Style_Main::Style_ID_Program_SN & "/"  & Style_Main::Style_ID_Program_SN & "_Art_BW/"  & Style_Main::Style_ID_Style_Code & "_BW_Front_"  & Style_Main::Style_Graphic_3_Count_BW_Front  & "." & Case (  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 1; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 2; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 4 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 5 )); 3; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_JPG_BW_Front_Sketch ; 3 ) ; 3 )) ) ]  Export Field Contents [ Style_Main::Style_Graphic_JPG_3_BW_Front; “$filepathjpg” ]  Clear [ Style_Main::Style_Graphic_JPG_3_BW_Front ]  [ Select ]  Go to Field [ Style_Main::Style_Graphic_JPG_3_BW_Front ]  Insert Picture [ “$imagemacjpg” ]  [ Reference ]  Insert File [ Style_Main::Style_Graphic_3_File_JPG_BW_Front; “$filepathjpg” ]  [ Reference ]  #BW Front File  Show Custom Dialog [ Title: "IMPORT JPG"; Message: "Import " & Get (ScriptParameter) & " creator file."; Buttons: “OK” ]  Set Variable [ $version; Value:Style_Main::Style_Graphic_3_Count_BW_Front ]  Clear [ Style_Main::Style_Graphic_3_Creator_BW_Front ]  [ Select ]  Go to Field [ Style_Main::Style_Graphic_3_Creator_BW_Front ]  Insert Picture [  ]  [ Reference ]  Set Variable [ $filepathfile; Value:$filepathserver & "MondettaEnterprise/Groups/ERP/Documents/Programs/"  & Style_Main::Style_ID_Program_SN & "/"  & Style_Main::Style_ID_Program_SN & "_Art_BW/"  & Style_Main::Style_ID_Style_Code & "_BW_Front_File_"  & Style_Main::Style_Graphic_4_Count_BW_Back  & "." & Case (  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 1; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 2; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 4 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 3; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 3 )) ) ]  Set Variable [ $imagemacfile; Value:$imagepathserver & "MondettaEnterprise/Groups/ERP/Documents/Programs/"  & Style_Main::Style_ID_Program_SN & "/"  & Style_Main::Style_ID_Program_SN & "_Art_BW/"  & Style_Main::Style_ID_Style_Code & "_BW_Front_File_"  & Style_Main::Style_Graphic_4_Count_BW_Back  & "." & Case (  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 1; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 2; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 4 )) ;  If ( Middle ( ( Right ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 5 )); 3; 1 ) ; "."; Right  ( GetValue ( Style_Main::Style_Graphic_3_Path_Creator_BW_Front_Path ; 3 ) ; 3 )) ) ]  Export Field Contents [ Style_Main::Style_Graphic_3_Creator_BW_Front; “$filepathfile” ]  Insert File [ Style_Main::Style_Graphic_3_Creator_BW_Front; “$filepathfile” ]  [ Reference ]  End If  





Thanks
Michael










MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-02-10 01:11 PM - Post#359637     - Post Rank:             
    In response to MichaelL


So I just tried another otption by calling another script and passing the created file path, because this actually had the file extension at the end, but not sure why it didn't pick it out.

This is the new script..
Code:

  04 Import Export04-0330 Image Check  Set Variable $importfilepathValue:Get ScriptParameter ) ]  Set Variable $periodValue:Position $importfilepath "." ) ]  //  If [ $period + 1  ≠ "jpg" ]  If [ Right ( $importfilepath ; 3 ) ≠ "jpg" or Right ( $importfilepath ; 4 ) ≠ "jpeg" ]  //  If [ Middle ( $period ; $period + 1 ; 3 ) ≠ "jpg" ]  Show Custom Dialog [ Title: "Wrong File type"; Message: "You are trying to import a NON JPEG file, Please try again.  Thankyou"; Buttons: “OK”, “Cancel” ]  Exit Script [  ]  End If   














raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-02-10 01:32 PM - Post#359638     - Post Rank:             
    In response to MichaelL

Hi

"Set Variable [ $importfilepath; Value:Get ( ScriptParameter ) ]"

Actually, what is stored into the Script Parameter ?

And where/when was it stored ?
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-02-10 01:43 PM - Post#359639     - Post Rank:             
    In response to raybaudi

The actually file path that is created in the parent script that we store in the container field.
The reason we have to do this is that we have users in china on windows machines and we are on Macs and as we don't store the pics in the DB we need to create these file paths.
Not my design.
Picture is what would be stored.

Attachment: Picture_3.png (23.54 KB) 32 View(s)












raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-02-10 01:54 PM - Post#359640     - Post Rank:             
    In response to MichaelL

  • MichaelL Said:
The actually file path that is created in the parent script that we store in the container field.



Could you check with the Data Viewer ?

( or a Custom Dialog ? )

04 : Import & Export: 04-0330 > Image Check
Show Custom Dialog [ Get ( ScriptParameter ) ]
...
...
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-02-10 02:04 PM - Post#359641     - Post Rank:             
    In response to raybaudi

Actually I have a habit of running my scripts through debugger with the data viewer also open so I can see whats going on, so ya this is whats coming into the child script.











raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-02-10 02:10 PM - Post#359643     - Post Rank:             
    In response to MichaelL

So your Custom Dialog appears ?

Show Custom Dialog [ Title: "Wrong File type"; Message: "You are trying to import a NON JPEG file, Please try again.
Thankyou"; Buttons: “OK”, “Cancel” ]
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-02-10 02:17 PM - Post#359644     - Post Rank:             
    In response to raybaudi

Ya it does even when the file is a jpg or jpeg.
Baffle's me why.










raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-02-10 02:26 PM - Post#359645     - Post Rank:             
    In response to MichaelL

This is why I think that the $importfilepath is actually EMPTY
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-05-10 06:21 AM - Post#359717     - Post Rank:             
    In response to raybaudi

So I ran through the script again this morning and took a snap shot. All required info seems to be there.


Attachment: Picture_4.png (256.76 KB) 28 View(s)












raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-05-10 07:04 AM - Post#359718     - Post Rank:             
    In response to MichaelL

The only thing that I can suggest is to re-write the step:

If [ Right ( $importfilepath ; 3 ) ≠ "jpg" or Right ( $importfilepath ; 4 ) ≠ "jpeg" ]

Pay attenction to the $var or write directly:

If [ Right ( Get ( ScriptParameter ) ; 3 ) ≠ "jpg" or Right ( Get ( ScriptParameter ) ; 4 ) ≠ "jpeg" ]
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-05-10 12:52 PM - Post#359736     - Post Rank:             
    In response to raybaudi

Well that didn't work either.
There's gotta be an easier way.










comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-05-10 01:28 PM - Post#359738     - Post Rank:             
    In response to MichaelL

This expression:

Code:

  Right $importfilepath ≠ "jpg" or Right $importfilepath ≠ "jpeg" 





will ALWAYS evaluate as true. Try using AND instead of OR.


See also:
http://fmforums.com/forum/showtopic.php?tid/189757/post/265392/#265392











raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-05-10 03:14 PM - Post#359750     - Post Rank:             
    In response to comment

  • comment Said:
...will ALWAYS evaluate as true



Good catch !

Even this may work:

Code:

 If [ Right Get ScriptParameter ) ; ) = "jpg" xor Right Get ScriptParameter ) ; ) = "jpeg" 



Daniele
--------------------------------
I'm sorry for my English











comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-05-10 03:43 PM - Post#359753     - Post Rank:             
    In response to raybaudi

A simple OR would also work - they cannot be both true at the same time.










raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-05-10 03:52 PM - Post#359754     - Post Rank:             
    In response to comment

... not to count that we are looking for TRUE when the extension is different from jpg/jpeg.

If [ not ( Right ( Get ( ScriptParameter ) ; 3 ) = "jpg" or Right ( Get ( ScriptParameter ) ; 4 ) = "jpeg" ) ]



That was a subtle thing... I think that I may be wrong other times.
Daniele
--------------------------------
I'm sorry for my English











comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-05-10 04:25 PM - Post#359757     - Post Rank:             
    In response to raybaudi

  • raybaudi Said:
... not to count that we are looking for TRUE when the extension is different from jpg/jpeg.



It doesn't matter:

not ( a or b )

is the same thing as:

not a and not b










raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-05-10 04:42 PM - Post#359761     - Post Rank:             
    In response to comment

I meant:

a ≠ "jpg" or a ≠ "jpeg"

is wrong and must be corrected with:

a ≠ "jpg" and a ≠ "jpeg"

or

not ( a = "jpg" or a = "jpeg" )
Daniele
--------------------------------
I'm sorry for my English











MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-06-10 09:03 AM - Post#359798     - Post Rank:             
    In response to comment

  • comment Said:
A simple OR would also work - they cannot be both true at the same time.


Simple "OR", what do you mean by this.
Oh by the way the "AND" worked like a charm thanks.
Unfortunately the extension checking has uncovered another major issue when creating the file path. If a file has an extension of "JPG" then no problem the path is created/imported, but if its "JPEG" the path create chops of the "J" and you get an extension of "PEG" which due to the checking will now not go through.
So I'm going to have to modify that bit of script, or get the guy who wrote it to make the change.
I'll save that for another post.

Thanks again











comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-06-10 09:38 AM - Post#359804     - Post Rank:             
    In response to MichaelL

You can the extract the extension by =

Let ( [
len = Length ( FileName ) ;
pos = Position ( FileName ; "." ; len ; -1 )
] ;
Case ( pos ; Right ( FileName ; len - pos ) )
)


  • Quote:
Simple "OR", what do you mean by this.



I meant there was no need to use XOR in Daniele's example. OR is simpler, since it can exit after finding the first proposition true.










MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-07-10 06:59 AM - Post#359866     - Post Rank:             
    In response to comment

  • comment Said:
You can the extract the extension by =

Let ( [
len = Length ( FileName ) ;
pos = Position ( FileName ; "." ; len ; -1 )
] ;
Case ( pos ; Right ( FileName ; len - pos ) )
)




So if I understand this correctly I have a field with say 121 characters and the extension is "JPG". Position would find "." at position 118. The case statement would resolve to 3. I would then have to script to pickup the last 3 places of the field or?
Where is the "3" stored, in "pos"?

Thanks
Michael











raybaudi 
ChindoguMaker
Posts: 2769
raybaudi

Loc: Italy Rome
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Intermediate



Tweet This! Tweet This Post!
07-07-10 07:14 AM - Post#359869     - Post Rank:             
    In response to MichaelL

No, the 3 isn't stored anywhere ( infact it can be 4 or other numbers ).

If there is a dot, it is the result of the calculation: len - pos
Daniele
--------------------------------
I'm sorry for my English











comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-07-10 08:27 AM - Post#359879     - Post Rank:             
    In response to MichaelL

  • Quote:
The case statement would resolve to 3.



No, the Case statement would return "JPG".


  • Quote:
Where is the "3" stored, in "pos"?



As Daniele explained, the expression:

Right ( FileName ; len - pos )

would evaluate in your example as:

Right ( FileName ; 121 - 118 )










MichaelL 
enthusiast
Posts: 31
MichaelL

Loc: Canada
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Cross Platform
Skill: Entry Level



Tweet This! Tweet This Post!
07-16-10 08:45 AM - Post#360671     - Post Rank:             
    In response to comment

Thanks Daniele and comment for your help.
The solution works but seems our users are quite creative when uploading files to the server. Instead of saving PhotoShop files as JPG they just change the file extension. As soon as it hits windows it craps the FM app. So its just becomes more work for them when they have to redo the files the proper way. They will learn, maybe.

Thanks again
Michael










comment 
consultant
Posts: 15780
comment

Post Rank (AVG):
            


FMP: 7 Advanced
OS: Mac OS X Panther



Tweet This! Tweet This Post!
07-16-10 09:01 AM - Post#360672     - Post Rank:             
    In response to MichaelL

http://www.quotesstar.com/quotes/b/build-something-thats-foolproof-and-1 520...










fseipel 
apprentice
Posts: 125

Loc: Columbus, Ohio
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Windows XP
Skill: Expert



Tweet This! Tweet This Post!
07-18-10 01:54 PM - Post#360786     - Post Rank:             
    In response to MichaelL

You might wish to try the command line utility TRID which will identify the file type. Filemaker can then handle it accordingly based on TRID's output. http://mark0.net/soft-tridnet-e.html










Your continued generosity and support of FMForums is greatly appreciated.
Fenton 
Carpal Tunnel
Posts: 4987
Fenton

Loc: San Diego, CA
Post Rank (AVG):
            


FMP: 10 Advanced
OS: Mac OS X Leopard

Member: TechNet, FBA
Skill: Advance

 FMPug

Tweet This! Tweet This Post!
07-18-10 04:07 PM - Post#360792     - Post Rank:             
    In response to fseipel

On a Mac there is the background application "Image Events", and its similar command line counterpart "sips." The following uses sips and returns the graphic format of the file (hopefully). I don't have any inserted without an extension, and FileMaker will not let me Insert one.

You'd need to coerce a FileMaker file path, used to Export Field Contents, to a safe Unix style file path (instead of the choose file line I'm using below, so you can try the routine in AppleScript Script Editor. You would run this via the Perform AppleScript command.

You can use Abs ( Get (SystemPlatform)) = 1 // Mac, to fork your script steps

-- denotes a comment line in AppleScript


-- choose file, returns Mac alias path; coerce to safe Unix path
set img to quoted form of POSIX path of (choose file)

-- "example: '/Users/fej/Downloads/zMisc/PDFs images/Google_Truck' "
-- the above is the filepath syntax the sips command needs

set imgFormat to do shell script "sips -g format " & img & " | tail -n 1 | cut -d ':' -f 2 | cut -c 2-"
-- "png"
http://fentonjones.com











Icon Legend Permissions Topic Options
Print Topic

Email Topic

1253 Views
Welcome Guest...
Enter your username and password to login. If you do not have a username you can register one here

Username

Password

Remember me. Help



Forgot Password...


Quick Links
Recent Posts
Active Topics
No Replies
Recent Files
Functions & Scripts
FileMaker Pro Help
FileMaker on Twitter
FileMaker Marketplace

Custom Search

Find FileMaker Developers

Don't have time to wait,
hire a developer now!

Recent Members
Welcome them to our community!
Find FileMaker Jobs

Want a new career?
Find your new job now!

Joy of Tech
Latest Joy of Tech!

Recent Topics
Recent Hot Topics
Contribute
With your generosity we can make some real magic happen!. Support your favorite online FileMaker community...
FM Forums.com


Click here...


Or a Donation of any amount.


Thanks for your support!

Active Blogs
0 Recent blogs:
People to Post Lately in this Topic
MichaelL
raybaudi
comment
fseipel
Fenton
FM Forums Advertisers


FusionBB™ Version 3.0 FINAL | ©2003-2010 InteractivePHP, Inc.
Execution time: 0.601 seconds.   Total Queries: 317   Zlib Compression is on.
All times are . Current time is 01:35 PM
Content ©1996-2008 Ocean West Consulting, Inc. All Rights Reserved
Ocean West Consulting, Inc. can not and will not be held responsible for any of the contents in this site.
FM Forums™ is a trademark of Ocean West Consulting, Inc an independent entity, not affiliated with FileMaker Inc.
FileMaker® is a registered trademark of FileMaker Inc.
Top