Concerning variables...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Agent Jones
    Forum Member
    • Jan 2004
    • 53

    Concerning variables...

    This is just an example for why I don't like AMS 5, concerning to variables of course.

    Code:
    SysUser = System.GetUserInfo();
    [b][color=red]RegOwner[/color][/b][color=red][/color] = Table.Concat(SysUser, ";", 1, 1);
    result = Dialog.Message("Notice", "[b][color=red]RegOwner[/color][/b][color=red][/color]", 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:

    Code:
    %Result% = Dialog.MessageBox("Notice", "[b][color=red]%RegOwner%[/color][/b][color=red][/color]", 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
    Indigo Rose Staff Member
    • Feb 2001
    • 2729

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

    What you want is this:

    Code:
    SysUser = System.GetUserInfo();
    RegOwner = Table.Concat(SysUser, ";", 1, 1);
    result = Dialog.Message("Notice", [color=blue]RegOwner[/color], 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:

    Code:
    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.
    --[[ Indigo Rose Software Developer ]]

    Comment

    • rhosk
      Indigo Rose Customer
      • Aug 2003
      • 1698

      #3
      That actually doesn't work Lorne, but this should help out -



      Regards,

      -Ron

      Music | Video | Pictures

      Comment

      • Agent Jones
        Forum Member
        • Jan 2004
        • 53

        #4
        Originally posted by rhosk
        That actually doesn't work Lorne, but this should help out -




        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:

        Code:
        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".

        Comment

        • CWRIGHT
          Indigo Rose Customer
          • Jun 2002
          • 42

          #5
          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);

          Comment

          • Lorne
            Indigo Rose Staff Member
            • Feb 2001
            • 2729

            #6
            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:
            Code:
            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.
            --[[ Indigo Rose Software Developer ]]

            Comment

            Working...
            X