jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Mon Feb 28, 2005 12:03 pm Post subject: Brackets in filenames |
|
|
A couple of times I have seen the claim that VDS doesn't allow brackets in filenames. Following something that I did this morning, I think I understand the problem.
I had a bit of code like this, to try to generate a unique filename:
| Code: | %I = 1
while @file(%%rootdir\%%name(%I).txt)
%I = @succ(%I)
wend |
This went into an endless loop. I established that the expression:
%F = @file(%%rootdir\%%name(%I).txt)
resulted in a value for %F of ".txt)". The first terminating btacket was being used as the end of the function.
This is not a bug in VDS, but it is an easy trap to fall into. The reason is that VDS does not require you to put quotes round text that is simply text. Other languages do, so that you would have to write something like:
%F = @file(%%rootdir+"\+"%%name+"("+%I+").txt")
and the compiler would not become confused.
VDS would probably be a better language, technically, if it required strings to be quoted, but despite the occasional problem it causes, I'm glad that you don't have to.
PS: After previewing this posting I notice that VDSWorld displays the warning: "inconsistent @ character, opening bracket and closing bracket count on previous line" in my code. Now, the code actually is not wrong code. Although in my example "@file(%%rootdir\%%name(%I)" followed by ".txt)" clearly is nonsense, there could be cases where you want to have brackets in strings that result in a mismatched count. But perhaps it would be a worthwhile addition to the VDS 6 compiler to display a similar warning. _________________ The Tech Pro
www.tech-pro.net |
|