comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Rename files using IDL - is it possible?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Rename files using IDL - is it possible? [message #72127 is a reply to message #72010] Fri, 06 August 2010 12:02 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Thu, 5 Aug 2010 23:40:15 -0700 (PDT), LNpellen wrote:

> I'm using IDL 7.1 and Windows XP
>
> Now I've tried spawn and FILE_DELETE and OPENR with /DELETE and
> discovered a bit strange behaviour (I think):
>
> The spawn command is either incorrect or not working
> IDL> spawn, 'DEL C:\testaaa.txt' (where the aaa is three norwegian A
> with a ring)
>
> FILE_DELETE and OPENR with /DELETE is not working if the filename is
> defined by dialog_pickfile, but is woring if the filename is defined
> with a hard coded string
>
> Not working if a=dialog_pickfile(), working if a='C:
> \testaaa.txt' (again a is a ring)
> IDL> FILE_DELETE, a, (/NOEXPAND_PATH)
> IDL> OPENR, UNIT, a, /DELETE, /GET_LUN & FREE_LUN, UNIT
>
> I.e. if the string is hardcoded (which I certainly cannot do in my
> program) the commands except spawn works. I did also try a(0) with
> dialog_pickfile to assure it's a string, not an array of strings.
>
> The hard coded A is a copy of the print of A using dialog_pickfile so
> I find no difference in A hard coded or A defined by dialog_pickfile.
>
> Now any suggestions?

Hi LN,

I don't know if you can (or like to) update to Version 8.0 at this
time. So here is what I figured out. In IDL 7.x the strings
a1=dialog_pickfile()
and
a2='C:\testaaa.txt' ; Workbench command line,
; replace a by A_circle!
are different:
print,byte(a1),format='(20z3.2)'
; 43 3a 5c 74 65 73 74 c5 c5 c5 2e 74 78 74
print,byte(a2),format='(20z3.2)'
; 43 3a 5c 74 65 73 74 c3 85 c3 85 c3 85 2e 74 78 74
a1 is the Windows ANSI (or whatever you call it) representation of the
file name, and a2 is UTF-8.

It may be a suitable workaround for you, to change each c5 to c385 in
the byte representation.

By the way, I am running Windows and IDL 7.1.2. In my installation all
three methods (spawn, file_delete, and openr,/delete) are working
without errors for both, a1 and a2. But to be honest, I really don't
know why! How does IDL or Windows know, that "a1 ist ANSI" and "a2 is
UTF-8"?

HTH, Heinz


P.S.: Could it be, that IDL/Windows first tries to treat the file_name
as an UTF-8 string. If it finds a matching file, it deletes it. And if
IDL/Windows does not find a matching file, that the string is
converted from ANSI to UTF-8 for trying to delete that file? Seems to
be a very dangerous story.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: "perspective-ized" axis numbering in iSurface
Next Topic: Re: "Fatal error: IDL has encountered a fatal error and will now exit."

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:45:55 PDT 2025

Total time taken to generate the page: 2.07831 seconds