Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 4:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Getting filename
PostPosted: April 18th, 2007, 9:06 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
This should be simple but I cannot seem to get my head around it!

How can I get just the filename from the text below?

"C:\Documents and Settings\Clive.HOME\My Documents\A presentation about me.ppt"

This is stored in a variable that has been got using the 'file browse' action. I need to be able to get any filename selected.

Any help would be appreciated as always.

Regards

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 18th, 2007, 10:31 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Clive,

For want of a better method, I'd read the string backwards, checking for the '\' character. When I found it, I'd read it into a substring from there -1 to end.

Mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 19th, 2007, 10:04 am 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Clive,
Loved this check...
Exhausted the scripting ideas on getting this done, characterset details seems to ignore "\" all together hence couldn't read a character at a time and break the line up at the "viewable" "\" character.
in UNIX there is a command basename and dirname that can split the data for you, google basename.exe, a few sources for this bit of code ported to windows environment.


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 19th, 2007, 11:04 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Good old fashioned ASCII :-)

Enjoy

function theGetPath()
{
var myPathLength = myPath.length //finds length of the path
var myLoop = 0
var myFound = false

while (myFound == false)
{
if (myPath.charCodeAt(myPathLength) == 92) myFound = true //escapes when '\' has been found
if (myPathLength == 0) myFound = true //escapes loop once end of string is reached.
myPathLength--
} //EOWhile

myFilename = myPath.substring(myPathLength+2,myPath.length) //Read filename substring in myFilename publication variable.

}

Mackavi

P.S

http://www.asciitable.com/


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 19th, 2007, 11:25 am 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
mackavi,
Hi was following that route and hit a snag, please try echoing each characters dec value of the string given, for some reason, I can get "\" to be seen within opus unless it is escaped "\\"

var name = "C:\Documents and Settings\Clive.HOME\My Documents\A presentation about me.ppt"

within opus, character count is less by equal number of "\".


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 19th, 2007, 11:38 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi eomc,

Sorry, a little confused. Are you trying to read the filename from the path like Clive?

I entered the string, into my test publication:

C:\Documents and Settings\Clive.HOME\My Documents\A presentation about me.ppt

and it extracted A presentation about me.ppt part.


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 19th, 2007, 4:17 pm 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
mackavi,
Got to my Opus PC and it works fine...thanks


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Getting Filename
PostPosted: April 19th, 2007, 9:07 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
Mackavi,

Many thanks - this works a treat.

I knew what I wanted to do but had not seen the charCodeAt function.

Many thanks for this and it is good to see that others can also benefit from it as well.

Regards

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 19th, 2007, 11:31 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
It isn't in the manual :-(

Glad it helps.


Top
 Profile Visit website  
 
 Post subject: CharCodeAt
PostPosted: April 20th, 2007, 6:12 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
It may not be in the manual but it is in the online help. I looked for 'text objects' and it is not listed as a text opbect function - a bit odd perhaps!

Clive


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2007, 5:12 am 
Offline

Joined: November 28th, 2004, 6:05 am
Posts: 141
Location: USA
Here's some more that's not in the help or the manual

this takes the full path in <a>
and returns the file name in <b>

a = escape(a)
a=a.substring(a.lastIndexOf("%5c",String.length(a))+3,String.length(a))
b=unescape(a)

HTH
Chris

_________________
Opus Resources and Services


For this message Chris Jones has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: escape
PostPosted: April 21st, 2007, 8:50 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
Very interesting as usual from you Chris!

Where does the 'escape' bit come from?

Regards

Clive


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 21st, 2007, 11:58 pm 
Offline

Joined: November 28th, 2004, 6:05 am
Posts: 141
Location: USA
Hi Clive

escape and unescape come from EMCA
they convert and unconvert special chars to and from hex
(the hex for \ is %5c)

these two functions have been included in Opus since V2
but have yet to be documented

Really, I never thought they would be useful outside of
PostWebData until this came up.

Cheers
Chris

_________________
Opus Resources and Services


For this message Chris Jones has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 22nd, 2007, 12:22 am 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Chris Jones,
A few weeks back I downloaded a pdf on ECMAScript, and on reading the escape/unescape from this query, I found it tacked away in that long document on this programming language, Would I assume rightly that opus has implemented all ecmascript functions an that they are not fully documented in opus, or is it that a subset of the functions available in ecmascript have been implemented?


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 22nd, 2007, 12:44 am 
Offline

Joined: November 28th, 2004, 6:05 am
Posts: 141
Location: USA
No, there are only a few which are not included
in the documentation.
But there are several that are reserved for possible
future implementation.

Here are the undocumented ones that are currently functional

escape()
unescape()
array.sort()
array.reverse()

HTH
Chris

_________________
Opus Resources and Services


For this message Chris Jones has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 34 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group