Re: Setting a dirty flag for a file

2011-07-21 Thread Bill Vlahos
I use it in InfoWallet and It is terrific but it isn't available any longer. 

Bill Vlahos

Sent from my iPhone

On Jul 21, 2011, at 5:00 PM, Ken Ray  wrote:

>> But don't forget that the modifiedMark property only showed up in LC 4.6, 
>> and Charles said he's using v. 4.0.
> 
> True, but FYI Sean Shao has an external that works with 4.0 that does the 
> same thing. I've been using it in Stykz for quite a while. You can contact 
> her if you need it...
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: k...@sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Ken Ray
> But don't forget that the modifiedMark property only showed up in LC 4.6, and 
> Charles said he's using v. 4.0.

True, but FYI Sean Shao has an external that works with 4.0 that does the same 
thing. I've been using it in Stykz for quite a while. You can contact her if 
you need it...

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Web Site: http://www.sonsothunder.com/  

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Charles Szasz
Mark,

Thanks very much! I work on this tonight. 

Sent from my iPad

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Peter Brigham MD
On Jul 21, 2011, at 4:02 PM, Mark Schonewille wrote:

> Hi Charles,
> 
> I read your e-mail again. I understand that you want to know whether one or 
> more fields have changed, not whether a file is open.
> 
> Usually, I generate an md5Digest and save that:
> 
> on closeField
>  makeDigest 
> end closeField
> 
> on makeDigest
>  put empty into myDigest
>  repeat with x = 1 to number of fields
>put md5Digest(fld x & myDigest) into myDigest
>  end repeat
>  set the cDigest of this stack to myDigest
> end makeDigest
> 
> function dataChanged
>  put empty into myDigest
>  repeat with x = 1 to number of fields
>put md5Digest(fld x & myDigest) into myDigest
>  end repeat
>  return (the cDigest of this stack is myDigest)
> end dataChanged
> 
> You just will have to figure out what is a smart event to check the digest: 
> closing a field, closing a window, opening a window, refreshing the file 
> menu, etc.
> 
> When you close the window, you might want to do this:
> 
> on closeStackRequest
>  if dataChanged then
>answer "Do you want?" with "Don't Save" or "OK" or "No"
>if it containt "Don't" then
>  exit closeStackRequest
>else if it is "No" then
>  pass closeStackRequest
>else
>  // do your saving stuff here
>  // return true if the file was saved
>  if the result is true then
>pass closeStackRequest
>  end if
>end if
>  end if
> end closeStackRequest


I use a frontscript -- wholesale is better than retail:

on closefield
   setDirty
   pass closefield
end closefield

on setDirty tf
   if tf = empty then put true into tf
   put the version into v
   replace "." with empty in v
   if v < 453 then exit setDirty
   -- version must be 4.5.3 or higher,
   -- or you just create a new customprop
   set the modifiedMark of stack "myStack" to tf
end setDirty

If you want to exclude certain fields, use a customprop to mark fields that 
shouldn't trigger setDirty when edited:

   set the the dontFlagDirty of fld "excludedFld" to true

Then in the closeField handler in the frontscript, insert as the first line

   if the dontFlagDirty of the target <> true then pass closefield

Changes other than field content that should be saved (radiobuttons or 
checkboxes, etc) can be handled, eg, with a mouseup handler in the frontscript, 
and suitable checks on the target. (Pass the mouseup!)

I also do:

on preopenstack
   set dirty false
   ...  ...
   ...
end preopenstack

-- Peter

Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Mark Schonewille
Hi Charles,

I read your e-mail again. I understand that you want to know whether one or 
more fields have changed, not whether a file is open.

Usually, I generate an md5Digest and save that:

on closeField
  makeDigest 
end closeField

on makeDigest
  put empty into myDigest
  repeat with x = 1 to number of fields
put md5Digest(fld x & myDigest) into myDigest
  end repeat
  set the cDigest of this stack to myDigest
end makeDigest

function dataChanged
  put empty into myDigest
  repeat with x = 1 to number of fields
put md5Digest(fld x & myDigest) into myDigest
  end repeat
  return (the cDigest of this stack is myDigest)
end dataChanged

You just will have to figure out what is a smart event to check the digest: 
closing a field, closing a window, opening a window, refreshing the file menu, 
etc.

When you close the window, you might want to do this:

on closeStackRequest
  if dataChanged then
answer "Do you want?" with "Don't Save" or "OK" or "No"
if it containt "Don't" then
  exit closeStackRequest
else if it is "No" then
  pass closeStackRequest
else
  // do your saving stuff here
  // return true if the file was saved
  if the result is true then
pass closeStackRequest
  end if
end if
  end if
end closeStackRequest

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce

On 21 jul 2011, at 21:35, Charles Szasz wrote:

> Devin and Mark,
> 
> Thanks for your suggestions! I think this is one of those areas that should 
> be covered by LiveCode in their Lessons. I would not be surprised that others 
> had questions about how to do this task.
> 
> Charles Szasz
> csz...@mac.com
> 
> 
> 
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Charles Szasz
Devin and Mark,

Thanks for your suggestions! I think this is one of those areas that should be 
covered by LiveCode in their Lessons. I would not be surprised that others had 
questions about how to do this task.

Charles Szasz
csz...@mac.com





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Devin Asay

On Jul 21, 2011, at 1:20 PM, Richard Gaskin wrote:

> Charles Szasz wrote:
> 
>> I am using Rev. 4.0. How do you set a "dirty flag" for a data
>> file that that has been saved but still open in your app stack?
>> My app creates a data file that saves the contents of 16 fields.
>> I have code to show an initial save dialog when the user makes
>> changes. I want to use a dirty flag to show another save box only
>> when closing the file if the user makes subsequent changes in the
>> data file.  Otherwise when the user closes the data file without
>> additional change no save dialog will be presented.
> 
> You can use a custom property for that, setting it to true whenever a 
> closeField triggers, and clearing it on save.
> 
> But better still would be to use the modifiedMark property of the stack, 
> which has the additional benefit of indicating unsaved changes by 
> darkening the closeBox on OS X.

But don't forget that the modifiedMark property only showed up in LC 4.6, and 
Charles said he's using v. 4.0.
> 
> Whichever flag you use, you'll want to check it in a closeStackRequest 
> handler, so you can prompt the user to save if needed.

For actually setting the flag you can do something as simple as comparing the 
contents of a field with the contents of an external file with each keystroke:

on rawKeyUp
# where tFilepath is a variable storing the full path to the saved file
if field "mycontent" = url ("file:" & tFilepath) then
  set the dirtyStack of this stack to true
else
  set the dirtyStack of this stack to false
end if
end rawKeyUp

HTH

Devin


Devin Asay
Humanities Technology and Research Support Center
Brigham Young University


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Richard Gaskin

Charles Szasz wrote:

> I am using Rev. 4.0. How do you set a "dirty flag" for a data
> file that that has been saved but still open in your app stack?
> My app creates a data file that saves the contents of 16 fields.
> I have code to show an initial save dialog when the user makes
> changes. I want to use a dirty flag to show another save box only
> when closing the file if the user makes subsequent changes in the
> data file.  Otherwise when the user closes the data file without
> additional change no save dialog will be presented.

You can use a custom property for that, setting it to true whenever a 
closeField triggers, and clearing it on save.


But better still would be to use the modifiedMark property of the stack, 
which has the additional benefit of indicating unsaved changes by 
darkening the closeBox on OS X.


Whichever flag you use, you'll want to check it in a closeStackRequest 
handler, so you can prompt the user to save if needed.


--
 Richard Gaskin
 Fourth World
 LiveCode training and consulting: http://www.fourthworld.com
 Webzine for LiveCode developers: http://www.LiveCodeJournal.com
 LiveCode Journal blog: http://LiveCodejournal.com/blog.irv

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Charles Szasz
Hi Mark,

Can you elaborate on what you are suggesting here and how you can do it? 

Charles Szasz
csz...@mac.com





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Setting a dirty flag for a file

2011-07-21 Thread Mark Schonewille
Hi Charles,

Isn't it sufficient to simply no close the file until you're done? You might 
need to keep records of open files, but if you do this properly, you could open 
them once and close them all when your app closes or if the user closes some 
window.

on openSomeFIle
  open file gFile
  // do stuff
end openSomeFile

on closeStack
  close file gFile
end coseStack

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce

On 21 jul 2011, at 20:45, Charles Szasz wrote:

> I am using Rev. 4.0. How do you set a "dirty flag" for a data file that that 
> has been saved but still open in your app stack?  My app creates a data file 
> that saves the contents of 16 fields. I have code to show an initial save 
> dialog when the user makes changes. I want to use a dirty flag to show 
> another save box only when closing the file if the user makes subsequent 
> changes in the data file.  Otherwise when the user closes the data file 
> without additional change no save dialog will be presented.
> 
> Thanks for your time! 
> 
> Charles Szasz
> csz...@mac.com
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Setting a dirty flag for a file

2011-07-21 Thread Charles Szasz
I am using Rev. 4.0. How do you set a "dirty flag" for a data file that that 
has been saved but still open in your app stack?  My app creates a data file 
that saves the contents of 16 fields. I have code to show an initial save 
dialog when the user makes changes. I want to use a dirty flag to show another 
save box only when closing the file if the user makes subsequent changes in the 
data file.  Otherwise when the user closes the data file without additional 
change no save dialog will be presented.

Thanks for your time! 

Charles Szasz
csz...@mac.com





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode