Digital Workshop

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Not a new question -- Filenames with spaces
PostPosted: May 27th, 2008, 10:00 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
I have Filenames that have spaces.

Using Opusscript when I enter the full pathname and filename directly, the command works and I get results reading the disk file.
Code:
/var mytextObj = OpenFile( "D:\\someDOCSfolder\\Filename with spaces 002.txt", false) ;


However, I want to have a variable for the path (w/o filename) and another variable for filenames. So script looks like this:
Code:
var shortPath = "D:\\someDOCSfolder\\" ;
var currFilename = "Filename with spaces 002.txt" ;
var mytextObj = OpenFile( shortPath + currFilename, false) ; //this fails to work
var test_for_File = FileExists( shortPath + currFilename ) ; // returns '1', File exists

Both ways continue into subsequent Read() or ReadLine() commands.
'OpenFile()' with complete string works. 'OpenFile()' with variables for Path + Filename does not work (filename having spaces).

I tried getting Quotes or Single-quotes around the var 'currFilename', but no luck.

Interesting that the 'FileExists()' command has no trouble with it.

So, how do I get 'OpenFile()' to work with a variable whose value has spaces?

TIA

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: May 27th, 2008, 11:00 pm 
Offline
Godlike
Godlike
User avatar

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

Tried it with your script. Added ReadLine and it read the file even with spaces in the file name.

Perhaps something else is a miss?

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: May 27th, 2008, 11:28 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Mack

Thanks.
'Yes', here's a bit of an update.

I did some more testing.
When I 'hardcode' a filename within the script as follows, it works for me too.
Code:
var setFilename00 = "myfile name that has spaces.txt" ;
var currFilename = setFilename00 ;


So I have to dig back further. I have the filenames stored in SQLite DB. These were generated using Paul's Directory Listing exe, and read from that result file into the DB. So the code I am using is
Code:
var currFilename = FName  ; 
// where FName is 1 field from the DB... Records_PubArray1[1][0]
That field seems to display a filename correctly when retrieved and shown in a Textbox with <var>. Apparently, something is lost in translation. I've tried 'toString' and 'valueOf' etc just in case, but no luck. It's not any issue with upper/lower case either.

Any suggestions what to look out for are appreciated.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: May 27th, 2008, 11:42 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
more info.

I created a new notepad text document in the same folder. Gave it a filename with spaces, and Copied that name.

Went into my sqlite DB and manually edited one of the records, replacing an existing Filename value by Pasting the name of new document.

Funny, testing with that Record back in Opus worked. So my conclusion is to look back further in the chain of events. Will keep you posted. Thanks, insanity postponed. :roll:

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: May 28th, 2008, 1:46 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Am posting some observations while fresh in my mind.

In tracing this back, here is what I think has happened. When developing the script, I must have had some errors within the function I was writing. When the OpenFile() command ran and did not find a valid matching file, it created a file with 0 Kbytes in that folder (named ~same but with .txt in the name).:?: My subsequent execution attempts with corrections to the scripted function may then have run 'okay' (as confirmed above), but found the 0 Kbyte file first (and not the 6KB file and so appeared not to display any text.

A lesson here?
So now I am putting the FileExists() as a condition before running the OpenFile(). Will have to reconstruct and clean-up from the beginning to make sure I've got all this right.

[Edit same day] Okay... working. Thanks.
Cleaned up the File operations and Read script. Went back and purged the target Folder and retested my 'workflow' with a fresh set of files. Works!! :)

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 46 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