Indigo Rose Software
  #1  
Old 04-07-2006
playmenow playmenow is offline
Banned
 
Join Date: Nov 2005
Location: Banned by moderator.
Posts: 264
Post Function: Run It Once

Thanks Adam for this awesome function! (Source = AMS5 Examples forum)

What do you do when you want your application to perform a certain set of actions - but only one time ever? This function does just that. It keeps track of whether or not the actions have been called before and will return true if they have been and false if they have not.

Place this code into your Global Functions section. Make sure to replace the text "Your_Application_Name" with your own unique application name.

Code:
--[[ This function will be used as a way to carry out an event
      the first time that the autorun is run. function ShowOnce(key)
      Always test to see if the value has been saved before]]
local Saved = Application.LoadValue("Your_Application_Name", key);
-- If it has not been saved before
if Saved == "" then
-- Save the value
Application.SaveValue("Your_Application_Name", key, "TRUE");
-- Return false
return false;
else
-- This means that the value has been saved before
return true;
end
end

You can call this function and use the result from anywhere. In this example, I put the following script into the first page's OnShow event. This will hide an object if it is not the first time that the application has been run.

Code:
-- call this function every time that the application is run.
Show = ShowOnce("ValueName");
if Show then
-- hide the object because it has been shown once before Label.SetVisible("Label1", false);
end
Reply With Quote
  #2  
Old 08-14-2006
goukilord10 goukilord10 is offline
Forum Member
 
Join Date: Mar 2005
Posts: 130
and where the data is saved when using Application.SaveValue ??
registry ?, HD ?
Reply With Quote
  #3  
Old 08-14-2006
TJ_Tigger's Avatar
TJ_Tigger TJ_Tigger is offline
Indigo Rose Customer
 
Join Date: Sep 2002
Location: Sol 3
Posts: 3,188
This data is stored in the registry in the following key.

HKEY_CURRENT_USER\Software\Indigo Rose\ACData.

HTH
Tigg
__________________
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function: Run it Once Adam AutoPlay Media Studio 5.0 Examples 1 04-07-2006 02:04 AM
Another tough one... Interaction between Web and AMS Agent Jones AutoPlay Media Studio 5.0 13 08-18-2005 03:10 PM
Function: Resize & Center an Image kpsmith AutoPlay Media Studio 5.0 Examples 0 05-17-2004 02:36 PM
Function: Parsing Command Line Arguments Brett AutoPlay Media Studio 5.0 Examples 0 05-13-2004 09:42 AM
HOWTO: Limit the Number of Times an Install can be Run Support Setup Factory 6.0 Knowledge Base 0 10-17-2002 03:58 PM


All times are GMT -6. The time now is 08:21 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software