[Học phần mềm] AutoPlay 11 Đặt thời hạn sử dụng

510
11./ Đặt thời hạn sử dụng
< Back – Mốt số ví dụ
A./ Đặt ngày hết hạn cho chương trình
Sau khi đặt thời hạn sử dụng, nếu đến ngày chỉ định sẽ hiện thông báo hết hạn và đóng chương trình
  • Nhấn Project > Actions > On Startup, nhập:
–Input your expiration date here, format YYYYMMDD
–(no spaces, dashes, slashes, etc. just use numbers)
–Below is the date Dec 12, 2003
Expiration_Date = “20031212”

–Get the system date in ISO format
–Date = YYYY-MM-DD
Date = System.GetDate(DATE_FMT_ISO);

–Remove the dashes in the ISO format date
–to reflect the format of our expiry date
–Date == YYYYMMDD
Date = String.Replace(Date, “-“, “”, false);

–test to see if the application is expired
if Date > Expiration_Date then
    –The application has expired
    Dialog.Message (“Application Expired!”, “Your copy of this application has expired!   This program will now exit.”);
    Application.Exit();
end

B./ Đặt số lần sử dụng chương trình
Sau khi đặt số lần sử dụng, nếu vượt quá số lần qui định sẽ hiện thông báo hết hạn
  • Nhấn Project > Actions > On Startup
— Set the number of times allowed
times_allowed = 30;

— Retrieve the number of times run and convert the value to a number
times_run = Application.LoadValue(“My Application”, “Has Been Run”);
times_run = String.ToNumber(times_run);

— Calculate the number of allowed run times remaining
times_remaining = (times_allowed – times_run)

— Check if this is the first time the application has been run
— Save the new number of times run value
if times_run == 0 then
    Application.SaveValue(“My Application”, “Has Been Run”, “1”);
else
    Application.SaveValue(“My Application”, “Has Been Run”, (times_run + 1));
end

— Check if the application has been run more times than allowed
if times_run > times_allowed then
    Dialog.Message(“Trial Period Over”, “This software has expired”);
    Application.Exit();
else
    Dialog.Message(“Trial Period”, “You can run this program “..times_remaining..” more times.”);
end

C./ Đặt thời hạn sử dụng là 3 ngày
  • Nhấn Project > Actions > On Startup, nhập:
— Initialize variables
days_left = 30;
date_installed = Application.LoadValue(“My Application”, “Date Installed”);
time_limit = 30; –the length of the trial period, in days

— Convert string value to number
date_installed = String.ToNumber(date_installed);

— Was date_installed 0 (non-existent)?
if date_installed == 0 then
  — Value was nonexistent, create it
    Application.SaveValue(“My Application”, “Date Installed”, System.GetDate(DATE_FMT_JULIAN));
else
  — Update days_left
    days_left = (date_installed + time_limit) – System.GetDate(DATE_FMT_JULIAN);
end

— Are there days left?
if days_left < 1 then
  — There are not any days left, alert user and exit.
    Dialog.Message(“Trial Period Over”, “This software has expired”);
    Application.Exit();
else
  — There are days left, alert user how many
    Dialog.Message(“Trial Period”, “You have “..days_left..” days left in your trial period.”);
end


 

THÔNG TIN GÓP Ý
        Quý thầy cô hoặc bạn đọc muốn đóng góp tài liệu, vui lòng gửi về:
    Fanpage: https://www.facebook.com/linhhoitrithuc (Chia sẻ tài nguyên miễn phí)
    Email: linhhoitrithuc@gmail.com  
Thống kê truy cập
  • Đang truy cập5
  • Hôm nay1,671
  • Tháng hiện tại13,529
  • Tổng lượt truy cập78,320
GIÁO ÁN THEO CHỦ ĐỀ
ĐỀ THI HK 2 TIỂU HỌC
giáo án theo công văn 5512
facebook
Đăng nhập
Hãy đăng nhập thành viên để trải nghiệm đầy đủ các tiện ích trên site
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây