Persist Data Across Sessions

guclusat

Tanınmış Üye
Süper Moderatör
Persist Data Across Sessions
It is often nice to add a personal touch to your Application, such as greeting the user by name whenever your application is run.

As an example, we will create an application that prompts the user for their name the first time it is run, and stores that data in the registry. Every subsequent time that the application is run, it will greet the user with the name that they have inputted:

  1. Place the following code in your Project's On Startup event:
Kod:
-- Load the last used user name
user = Application.LoadValue("Information", "Name");

-- was there a username stored?
if user == "" then
   -- Nope!   Prompt the user for their name.
    user = "Unknown User";
    user = Dialog.Input("Information Requested", "Please enter your full name:", "", MB_ICONQUESTION);
    Application.SaveValue("Information", "Name", user);
end

-- Output welcome message
Dialog.Message("Welcome", "Hello "..user..", welcome to my application");

Note: This example prompts the user to enter their full name the first time they run your application, and stores that value in the registry. Every subsequent time that the user runs your application a message will pop up on the screen greeting them by name.
 
Geri
Yukarı