View Full Version : DIsplay Variable
basehitter10
12-21-2004, 03:03 PM
Sorry for posting such an arcane question, but I am picking up AMS5 ob the fly coming from AMS 3......
I want to display the user's OS on my menu. In AMS3 I simply did assign it to a variable thisOS and put %thisOS% on my menu.
How is this done in AMS5. I am not clear on how to pull this off.
Thanks!
basehitter10
Protocol
12-21-2004, 03:06 PM
Variables in AMS5 are anything (with a few exceptions) that you define as such. For instance, to declare a variable (to set it up) you simply type:
MyVariable = "123";
In AMS3/4 you would have used %MyVariable%. Now when you want to display what the variable represents, you simply tell the program to display MyVariable.
if you try to tell the program to display "MyVariable" it will literally display the text MyVariable and not 123 (in this case). If you tell the program to display %MyVariable%, it will likely come up with an error because it thinks you're trying to display a variable labeld %MyVariable% which hasn't been declared (set up).
Now here's the AMS5 code to set a label object with their OS Name:
OSName = System.GetOSName();
Label.SetText("Name of Label Object", OSName);
Before you try and run the code, you'll need to define the Label Object which in this example is temporarily called "Name of Label Object". That is to say, you'll need to actually have a Label Object somewhere on your page called "Name of Label Object".
What the above code did was to first get the OSName from the user's system. Then it placed that value (OS Name) in a variable called OSName. Now you can do whatever you want with that.
Where you need to remember is to look at the drag and drop functions carefully. Sometimes the value they return is a Table. In AMS3/4, you actually had to manually place values into tables. In AMS5 (depending on the function) it will do whatevers best for the code (it thinks ahead and uses what it thinks you will want). This makes the code a lot smarter (smaller in total size), but can be a wee bit confusing to users of older versions at first.
Protocol
12-21-2004, 03:23 PM
If it does insert the value into a table, you can do any number of things to extract the value from the table and treat it as a variable. Although, this is another topic. Just remember to use the "Learn more about this function" links and see what type of return it's going to give you.
In the above mentioned case, the function "System.GetOSName();" returns a value. That value can be named whatever you want. I called it OSName in order to be clever and throw off every coder out there. ;)
Let me know if you need any more help getting acclimated. Trust me...it's well worth the effort!
Protocol
basehitter10
12-21-2004, 03:41 PM
When I insert a label object it wants to display the text "thisOS" rather than the variable value - I am still confused.
basehitter10
Intrigued
12-21-2004, 03:45 PM
If you are interested in learning more about the embedded language (LUA) from the perspective of Indigo Rose's documentation I would recommend either printing off (or buying such from them) the manual for AMS 5.
Also, take a look at the Computer Based Training--3-CD set on www.speedytraining.com that I.R. representative Corey personally did for the AMS community. The price is much cheaper (but the quality and ease-of-use are still top-notch!) than other training CD-ROMS I have purchased. I enjoy the one's I have and recommend them for those that want to "get serious" with AMS 5.
Don't forget to use this Website's SEARCH (http://www.indigorose.com/forums/search.php?) feature to find code snippets to help you along the way!
When all is said and done I believe that AMS built-in LUA language is MUCH easier to grasp and use over say C++!
Sincerely,
Make sure you don't enclose the variable in quotes (" ")
When you enclose a variable in quotes, AMS will display what has is enclosed within the quotes. I'll bet that if you remove the quotes from around your variable, you'll get the results your looking for.
Protocol
12-21-2004, 04:28 PM
Yeah...
Basicly, AMS5 doesn't use the % symbol for variables anymore. Instead, you just say this=that. Actually you'd type:
this = that;
So...this is the correct code:
ThisOS = System.GetOSName();
Label.SetText("Name of Label Object", ThisOS);
The above code will display the name of the OS.
and this is the incorrect code:
ThisOS = System.GetOSName();
Label.SetText("Name of Label Object", "ThisOS");
This code will display the actual text "ThisOS"
When you put anything in quotes...it means display exactly what is in the quotes. This is an important distinction in AMS5. Although this was also true n oder versions as well. If you typed "%Variable%" with the quotes, it too would have displayed the text %Variable% and not the value of the variable itself.
Just don't use quotes or the percentage signs in your variables.
Let me know if ya still need help... ;)
Corey
12-21-2004, 05:42 PM
Thanks for the plug I-man. :)
basehitter10
01-10-2005, 11:04 AM
Thanks all - I got it. It is a bit different than AMS3, but once you get the gist of it it's straightforward.
I got a copy of the training CD when I bought the software. Now I'll actually load it up and use it....lol
basehitter10
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.