How to compile in earlier versions using new keywords?

-hh hh at livecode.org
Sat Apr 9 10:47:06 EDT 2016


@William
A nifty workaround. But this means, that we have to make two
script versions, and even three versions as soon as LC 8 is
"unlinked" (wrt compatibility) from previous versions.
====
@Craig
I have some scripts where I use for example a switch for
the itemdelimiter.
if char 1 of the version < 7 then set itemdelimiter to CR
else set itemdelimiter to ("." & CR) 
This is especially useful for splitting to and combining from
arrays and makes sense for me.
Okay, itemdelimiter is not a keyword but a property, analogue.
====
@Jacqueline
Amazing!! As you say, the "do" compiles in LC 6:
on mouseUp 
  if char 1 of the version > 6 then 
    do "put trueword 1 of fld 1 into fld 2" 
  else put word 1 of fld 1 into fld 2
end mouseUp 
But this means, that we have to put all code for LC 7/8 that
should compile also in LC 6 and earlier into strings and then do
these strings. 
For example a long "repeat for each trueword tw in X ...".
This is close to Bill's method (read from fields).
====
I have an idea, that may be more comfortable:
If we could have a switch in LC 7+8 for parsing/compiling
that temporarily disables one of the commenting methods,
for example "//", we could use "version blocks" in new scripts:

// usual comment line for all versions
set slashCommentsOff to true
 // ... code for versions 7/8 only
 // ... code for versions 7/8 only
set slashCommentsOff to false
// usual comment line for all versions

This could analogously go on two times with switches
"hashCommentsOff" and "dashCommentsOff"
for later versions...

Just an idea.



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/How-to-compile-in-earlier-versions-using-new-keywords-tp4703270p4703274.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list