Can't Move Backward
Kay C Lan
lan.kc.macmail at gmail.com
Mon Jan 12 03:50:05 EST 2015
Will not solve Ray's problem but may help him and others in the future from
being bitten.
What with the consistent flow of updates (thank you), flavours of LC to
test (depending if Cocoa or Unicode is your top priority) or if you are
just testing verses in production; I was sick and tied of opening certain
stacks in the wrong version of LC. This was wasting my time so I created
the following handler - hAvoidStableRcDpConfusion.
It basically uses a naming convention of the actual file name - not the
stack name, which can be anything. The convention is filename & v & a
number & . [dot] condensed LC version* & . [dot] & livecode; i.e
uniCtestv5.671.livecode
* The condensed LC Version is scripturally created by taking what is
reported by 'revAppVersion()' and removing any . [dots] or - [dashes].
6.7.2_(dp1) becomes 672(dp1).
If you attempted to open uniCtestv5.671.livecode in LC 7.0.1 you'd be told
your are opening your stack in a different version of LC than intended and
asked if you want to Quit LC all together, Close the stack - so you can
work on another stack, or Rename the stack file name, which will
automatically duplicate the current stack and allow you to work on your new
stack in LC 7.0.1 without Quitting LC.
Apart from preventing me from working on important stacks in unstable
versions of LC, it automatically leaves a trail of working stacks in known
LC versions which are easy to identify if I do want to try out new features
and bug fixes.
To test, duplicate a less important stack and give it a name [filename
]v2.450.livecode. Open it and place the two handlers in the Stack's script
and Save. Quit LC. Open the duplicated stack. Unless you are using 4.5.0 a
dialog box should come up with the option Quit, Close or Rename. If you
choose rename you should be left with only 1 stack open, which is your
newly created triplicate; you should have your original file, the v2 450
file, and a new file with v3 and the version number of LC you are currently
using.
(watch for line wraps)
on preOpenStack
hAvoidStableRcDpConfusion
end preOpenStack
on hAvoidStableRcDpConfusion
--breakpoint
--only applies if you are working on a stack
if (environment() = "development") then
put revAppVersion() into tVersion
put the short name of this stack into tName
--as part of the duplication process it is not possible to open a
stack with the same name
--you get the 'purge' message. To work around this the original has
the word 'old' appended to it's name
--this allows the new stack to open with the correct name.
--If ever you need to revert to the original stack, when it opens it
will automatically change it's name back
--to the correct name by removing the 'old' suffix.
if (char -3 to -1 of tName = "old") then
put char 1 to -4 of tName into tName
set the name of this stack to tName
save this stack
end if
--IMPORTANT
--this handler ONLY works if your stack follows this naming
convention:
-- yourStackName.LCversion.livecode
--The LC Version does NOT contain dots,dashes or spaces, so 7.0.1-rc-2
= 701rc2
--ie yourStackName.701(rc2).livecode
--you can also include your own version numbers by appending v and a
number to the basic name; but it's not a requirement
--i.e. yourStackNamev5.672(dp3).livecode
--if you'd prefer to use some other naming convention you'll need to
amend
--BETWEEN HERE
replace "." with "" in tVersion
replace "-" with "" in tVersion
put the long name of this stack into tName
set the itemDelimiter to "/"
put item -1 of tName into tFullName
set the itemDelimiter to "."
put item 2 of tFullName into tShortName
--AND HERE
--only need to do anything if the names don't match
if (tVersion <> tShortName) then
answer warning "This stack is based on LC " & tShortName & ", but
you are using Version " & tVersion & "." & cr & \
"You may:" & cr & "Quit = Will close this stack and Quit LC
completely." & cr & \
"Close = Will close this stack but leave LC " & tVersion & "
running." & cr & \
"Rename = Will automatically duplicate this file a create a
new stack with a file name which includes " & tVersion & "." with "Rename"
or "Close" or "Quit" titled "LC Version to File Missmatch"
put it into tAnswer
switch tAnswer
case ("Quit")
quit
break
case ("Close")
if (the destroyStack of this stack = false) then
answer warning "Although your stack will disappear from
view it is still in memory!" & cr & "You can manually Purge the stack from
memory if necessary." titled "Stack Still In Memory"
end if
close this stack
break
case ("Rename")
set the itemDelimiter to "/"
put item 4 to -1 of tName into tOldName
--remove the quote from the end of the name
put char 1 to -2 of tOldname into tOldName
put tOldName into tNewName
replace tShortName with tVersion in tNewName
--complete the path name to the file.
put specialFolderPath("Home") & "/" & tOldName into
tOriginalName
put specialFolderPath("Documents") & "/" & tFullName into
tCopyName
put char 1 to -2 of tCopyName into tCopyName
put specialFolderPath("Home") & "/" & tNewName into tNewName
replace tShortName with tVersion in tFullName
put char 1 to -2 of tFullName into tFullName
put tFullName into tCurrentName
if (matchText(tFullName,"v(\d)\.",tVersion)) then
--increase our v number by 1
replace ("v" & tVersion & ".") with ("v" & (tVersion + 1)
& ".") in tFullName
end if
ask question "Confirm new file name:" & cr & "The current
File Name is: " & tCurrentName with tFullName titled "File Name"
put it into tAnswer
put tAnswer into item -1 of tNewName
revCopyFile tOriginalName,specialFolderPath("Documents")
rename tCopyName to tNewName
put the short name of this stack into tCurrentStack
put tCurrentStack & "old" into tOldStack
set the name of this stack to tOldStack
save this stack
open stack tNewName
set the destroyStack of stack tOldStack to
true
close stack tOldStack
break
end switch
end if
end if
end hAvoidStableRcDpConfusion
More information about the use-livecode
mailing list