Illegal characters in filename
Moderator: Rathinagiri
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Illegal characters in filename
Hello,
Sometimes I rename a DBF file with a dash like: OLD-FILE.dbf
When accessing this file it will give this runtime error: Illegal characters in alias: OLD-FILE.
How can I avoid or suppress this error?
Serge
Sometimes I rename a DBF file with a dash like: OLD-FILE.dbf
When accessing this file it will give this runtime error: Illegal characters in alias: OLD-FILE.
How can I avoid or suppress this error?
Serge
There's nothing you can do that can't be done...
- mustafa
- Posts: 1174
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: Illegal characters in filename
Hi Serge
See if it works with -> OLD_FILE.dbf ?
Greetings
Mustafa
See if it works with -> OLD_FILE.dbf ?
Greetings
Mustafa
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Illegal characters in filename
Hi Mustafa,
Yes, underscores are no problem!
Problem occurs when renamed by mistake with a dash (or maybe with some other illegal character).
So, I want to suppress "runtime error: Illegal characters in alias" by skipping these. Now I check if a dash is in the filename but there maybe others illegal chars....
Serge
Yes, underscores are no problem!
Problem occurs when renamed by mistake with a dash (or maybe with some other illegal character).
So, I want to suppress "runtime error: Illegal characters in alias" by skipping these. Now I check if a dash is in the filename but there maybe others illegal chars....
Serge
There's nothing you can do that can't be done...
Re: Illegal characters in filename
Hi Serge
Are you renaming inside a program or from (cmd or windows)
If from a program you could create a function to check for or remove illegal characters with chr() and asc() codes.
Are you renaming inside a program or from (cmd or windows)
If from a program you could create a function to check for or remove illegal characters with chr() and asc() codes.
All The Best,
Franco
Canada
Franco
Canada
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Illegal characters in filename
Renaming has happened outside a program and mostly not by me...
Serge
Serge
There's nothing you can do that can't be done...
- Claudio Ricardo
- Posts: 367
- Joined: Tue Oct 27, 2020 3:38 am
- DBs Used: DBF, MySQL, MariaDB
- Location: Bs. As. - Argentina
Re: Illegal characters in filename
Hi... i use this function to prevent invalid dbf field names:
With small modification it is used for table names.
Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Función ValidFieldName () Comprueba si el nombre ingresado es valido para campos DBF (retorna .T.)
// Creada por Claudio Ricardo 03/2021
Function ValidFieldName (cCadena)
LOCAL cValid := .T.
LOCAL i
If ValType (cCadena) <> "C"
Return .F.
EndIf
If SubStr (cCadena,1,1) $"0123456789" .OR. Len (cCadena) > 10
Return .F.
EndIf
For i = 1 To Len (cCadena)
If ! Lower ( SubStr (cCadena,i,1)) $"abcdefghijklmnopqrstuvwxyz0123456789_" // lista de caracteres permitidos
cValid := .F.
EndIf
Next
Return cValid
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
- AUGE_OHR
- Posts: 2096
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Illegal characters in filename
have fun
Jimmy
Jimmy
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Illegal characters in filename
Thanks Jimmy,
That's the solution ! Because of the nature of my program the 'USE' is in a loop from a DIR function
and my USE is this construction:
This now works perfect! Thanks again!
Serge
That's the solution ! Because of the nature of my program the 'USE' is in a loop from a DIR function
and my USE is this construction:
Code: Select all
IF lOpenMode
if cNew = 'NEW'
USE ( cDatabase ) EXCLUSIVE NEW ALIAS cALIAS
ELSE
USE ( cDatabase ) EXCLUSIVE ALIAS cALIAS
ENDIF
ELSE
if cNew = 'NEW'
USE ( cDatabase ) SHARED NEW ALIAS cALIAS
ELSE
USE ( cDatabase ) SHARED ALIAS cALIAS
ENDIF
ENDIF
IF !NETERR()
RETURN ( TRUE )
ENDIF
Serge
There's nothing you can do that can't be done...
- AUGE_OHR
- Posts: 2096
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Illegal characters in filename
hi,
same is when try to open "1234.DBF"
it will crash while ALIAS() "1234" is not valid
but it work with
p.s. this Way i can use Chinese Name of DBF
same is when try to open "1234.DBF"
it will crash while ALIAS() "1234" is not valid
but it work with
Code: Select all
USE 1234.DBF ALIAS "ONE"have fun
Jimmy
Jimmy
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Illegal characters in filename
Yes, I know! I replace cALIAS with 'xxxx'.
Serge
Serge
There's nothing you can do that can't be done...