SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
get the file extension of a file

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
get the file extension of a file
Author Message
bob



Joined: 14 Jan 2005
Posts: 1

Post get the file extension of a file Reply with quote

Is there a JAL command that I can get the filename and extension into
different variables? I see the FileSplitName but am looking really to
get the path, filename, extension separated.


Fri Jan 14, 2005 7:19 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7970

Post Re: get the file extension of a file Reply with quote

No, there is no such command, but here is how a way out

1. Simpliest method, (we expect 3 characters extension)

Dim file_name, string, "c:\\somedir\\somefile.ext"
Dim ext, string
Right file_name, 3, ext
MessageBox ext

2.Easy method (any extension; but assume no other dots in the file and path names)

Dim file_name, string, "c:\\somedir\\somefile.someext"
Dim ext, string
GetToken ".", file_name, ext
Set ext, file_name
MessageBox ext

3. The always work method! (any extension, any path, file name)

Dim file_name, string, "c:\\somedir\\somefile.someext"
Dim ext, string
Dim bs_pos, number

// get last dot and the following string
Reverse file_name, file_name
GetToken ".", file_name, ext
Reverse ext, ext

// check if there are backslahes
InStr ext, "\\", 1, bs_pos
If bs_pos, NO_EXTENSION, DONE

NO_EXTENSION:
Set ext, ""

DONE:
MessageBox ext

: Is there a JAL command that I can get the filename and extension into
: different variables? I see the FileSplitName but am looking really to
: get the path, filename, extension separated.

Fri Jan 14, 2005 7:38 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.