View Full Version : Determining the OS via APMS
Brunzwick
02-17-2005, 06:52 PM
I am trying to get APMS to recognize what OS version it is running on and show a warning if it is not NT based by using System.GetOSVersionInfo. According to the help, PlatformId should do the trick. Below is the code I am trying to use, however, it is not working. I am running the code as an On Startup Action so it will immediately jump to a warning page, play a horribly annoying sound in a loop, and eject the CD. Unfortunately, it never actually jumps pages, instead it goes to the first page on the menu.
-- Check for 9x systems and annoy if found
OS_info = System.GetOSVersionInfo();
if OS_info.PlatformId == 1 then
Page.Jump("Win9x");
else end
Intrigued
02-17-2005, 07:00 PM
I believe you need "1" instead of just 1.
It's looking for a number, when it needs to see a string (thus the double quotes use).
Intrigued
02-17-2005, 07:28 PM
Here's a sample code chunk I used for my testing purposes, for what it's worth:
-- Alert user on Win9x system
OS_info = System.GetOSVersionInfo();
if OS_info.PlatformId == "1" then -- Try this as "1" instead of just 1
Page.Jump("Win9x")
else
Dialog.Message("Notice", "This is an NTFS based system!")
end
csd214
02-18-2005, 01:10 AM
My reply is NOT breaking news; it's just a description of my leaning process.
It is always important to know what kind of variable is returned by the action; string, number, Boolean or table? The default ResultVariable is ALWAYS 'result'. Many times I wished that the default variable was more descriptive like: sResult, nResult, bResult or tResult.
Be aware: When you highlight the System.GetOSVersionInfo action in Action Property Dialog, this text is displayed:
Returns a table containing the version information of the operating system the user is running.
Press Next and highlight ResultVariable. The status pane displays: The name of the variable to store the result in. (does not tell much).
Previously I always entered the help doc to read about the returned value:
Returns
(table) <-- Really important information
At this stage I overlooked a great feature; the Quick Help:
When the cursor is on an action in the code window, it's action definition will be displayed in this field.
In this case you can read:
table System.GetOSVersionInfo()
I always change the variable name to make it more descriptive than 'result'; in this case something like tOS_info (I love that syntax convention).
When a table is returned, you have to look up the help doc to learn about the key names. With System.GetOSVersionInfo() all the keys are of type 'String'.. So Intrigued's advice is a hotshot (I hope the phrase is understood to be a compliment).
Intrigued
02-18-2005, 09:08 AM
My reply is NOT breaking news; it's just a description of my leaning process.
It is always important to know what kind of variable is returned by the action; string, number, Boolean or table? The default ResultVariable is ALWAYS 'result'. Many times I wished that the default variable was more descriptive like: sResult, nResult, bResult or tResult.
Be aware: When you highlight the System.GetOSVersionInfo action in Action Property Dialog, this text is displayed:
Returns a table containing the version information of the operating system the user is running.
Press Next and highlight ResultVariable. The status pane displays: The name of the variable to store the result in. (does not tell much).
Previously I always entered the help doc to read about the returned value:
Returns
(table) <-- Really important information
At this stage I overlooked a great feature; the Quick Help:
When the cursor is on an action in the code window, it's action definition will be displayed in this field.
In this case you can read:
table System.GetOSVersionInfo()
I always change the variable name to make it more descriptive than 'result'; in this case something like tOS_info (I love that syntax convention).
When a table is returned, you have to look up the help doc to learn about the key names. With System.GetOSVersionInfo() all the keys are of type 'String'.. So Intrigued's advice is a hotshot (I hope the phrase is understood to be a compliment).
Excellent point(s) and well explained!
Thanks csd214!
:yes
csd214
02-19-2005, 11:46 AM
Excellent point(s) and well explained!
Thanks for your kind words; and my post was in English! Of course this forum is NOT a language contest, but I appreciate to learn that I'm understood. My self-image enjoys reading the words from JimS:
You say that your English isn’t so good. You sure fooled me. Your posts are always written in better English, than many of us native speakers do, myself included. In fact, you appear to be so good at it, that it is very easy for me to forget that you haven’t been speaking it all your life.
I'm not lucky all the time, but I hope you get something to laugh about when I write something like:
"I is a Norwegian turkey…cluck, cluck" :D
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.