PDA

View Full Version : Concerning variables...



Agent Jones
02-25-2004, 09:55 AM
This is just an example for why I don't like AMS 5, concerning to variables of course.


SysUser = System.GetUserInfo();
RegOwner = Table.Concat(SysUser, ";", 1, 1);
result = Dialog.Message("Notice", "RegOwner", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);


The red partes highlight the variable - a very simple one - to be shown in the dialog. In v4, I would be making something like:


%Result% = Dialog.MessageBox("Notice", "%RegOwner%", Ok, Information)

And that would be all to show %RegOwner% info to the end-user. In v5 (first code), it shows RegOwner in the dialog (not the regowner - just "regowner" lol).


This really complicates my Activation Systems lol... I would like to use v5 cos I heard it interacts with SQL DB, something that would be very usefull...

Anyway, I think that if you can tell me what's wrong I will understand myself with the new variable system.


Thanks in advance.

P/S: I'll soon be posting a tutorial for how to make an Activation System with AMS 4 (people can try to convert it to v5)

Topic is being watched for replies.

Lorne
02-25-2004, 11:08 AM
Variables should not be quoted in actions. Anything in quotes is just a string.

What you want is this:


SysUser = System.GetUserInfo();
RegOwner = Table.Concat(SysUser, ";", 1, 1);
result = Dialog.Message("Notice", RegOwner, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

Instead of including variables inside strings, like you did in 4.0, you now simply attach variables and strings together, which is what programmers call "concatenation." It works using the .. or "concatenation operator," like this:


concatenated_string = "Hello " .. user_name .."! Nice to meet you.";

All this information and more is explained in the last chapter of the user's guide (Help > Getting Started) and in the scripting guide.

Reading the last chapter of the user's guide and all of the scripting guide is essential to anyone who wants to use 5.0 in any advanced way.

rhosk
02-25-2004, 11:15 AM
That actually doesn't work Lorne, but this should help out -

http://www.indigorose.com/forums/showthread.php?s=&threadid=6224&highlight=regowner

:)

Agent Jones
02-25-2004, 11:42 AM
Originally posted by rhosk
That actually doesn't work Lorne, but this should help out -

http://www.indigorose.com/forums/showthread.php?s=&threadid=6224&highlight=regowner

:)


Thank you rhosk... That question was made by me a while ago :).
OK, bad example, since it has an answer already.

What I really wanted was the "operator" - some character that would limit the variable (like the % in v4).

So imagine I would want to do this:


JDate = System.GetInfo (Julian Date)
Dialog.Message ("Debugging", "JDate") (probably the code isn't well written but that's not the point for the moment)

What would happen is that, according to what's happening currently, I would get in the dialog "JDate" instead of something like "2510023".

CWRIGHT
02-25-2004, 11:55 AM
As Lorne has mentioned:

Variables should not be quoted in actions. Anything in quotes is just a string.

so:

JDate = System.GetInfo (Julian Date)
Dialog.Message ("Debugging", "JDate")

should be:

JDate = System.GetDate(3);
Dialog.Message("Debugging", JDate);

Lorne
02-25-2004, 11:56 AM
LOL, I posted that so fast I didn't even read the code. Oops.

Of course, since GetUserInfo() returns a table you need to access the data within that table appropriately.


What I really wanted was the "operator" - some character that would limit the variable (like the % in v4).

So imagine I would want to do this:

JDate = System.GetInfo (Julian Date)
Dialog.Message ("Debugging", "JDate")
(probably the code isn't well written but that's not the point for the moment)

What would happen is that, according to what's happening currently, I would get in the dialog "JDate" instead of something like "2510023".

There is no such operator. Variables aren't automatically expanded in strings any more. (Which is actually a very good thing, for reasons that are a bit too technical to cover in this post, but it basically allows AutoPlay to be faster and more reliable.)

In order to accomplish what you want, just don't quote the variable name. Putting a variable name between quotes treats the name as a regular string. For example:

num = 5; -- num is a variable that contains 5

Dialog.Message("num is", num); -- displays '5' on the dialog

Dialog.Message("num is","num"); -- displays 'num' on the dialog

Anything between quotes is a string. A variable name inside quotes isn't going to act like a variable at all, 'cause it isn't a variable, it's just a string that happens to contain the same letters as a variable name.