Trouble with 'there is a'

Graham Samuel livfoss at mac.com
Fri Jan 27 06:37:34 EST 2012


Thanks to those who replied to point out a gross stupidity on my part - the example I gave wasn't a legal LiveCode statement. I was too tired to notice. Sorry for the waste of bandwidth. I found the response of the message box mysterious but at least I'll recognise it next time.

My real script did have two problem but they were quite different, and might be of interest.

1.  I had constructed a Windows-style path with "\" characters to fit in with a small VB script I wanted to run. This does work in some contexts, but not in this one: in normal circumstances (but not AFAICS in VB scripts) LC looks after the change from "/" to "\". I forgot that it was this path in the variable I was testing. It gave a strange result, but the obvious answer is "don't do it".

2. The form of my 'if' condition was
  
  if there is not a file myPath &"/" & myfilename

it turns out that the 'there is no' statement doesn't construct the string before the evaluation: you have to ensure the evaluation of the string by putting it in brackets as in

  if there is not a file (myPath &"/" & myfilename)

There is an obscure warning about this in the dictionary: "The there is no operator is implemented internally as a function, and therefore has lower precedence than other operators". So it's a precedence issue.

Graham

I wrote
> I'm  using LS 5.0.2. on Windows XP (OK, running under Parallels on a Mac). I'm getting unexpected results from the 'there is..' series of functions/commands - the dictionary says they're implemented as functions, which I can understand.
> 
> As a very simple test, in the message box I put:
> 
>   put (if there is a folder (the defaultFolder))
> 
> expecting to get 'true'. Instead I get the totally unexpected result:
> 
>   161,426,1,return (if there is a folder (the defaultFolder))
> 
> I suppose it's my fault, but what does this mean? Just to be clear, 'the default folder' does have a value - it's:
> 
>  C:/Program Files/RunRev/LiveCode 5.0.2
> 
> Puzzled
> 
> Graham




More information about the use-livecode mailing list