Results 1 to 3 of 3

Thread: Uninitialized variables

  1. #1
    Join Date
    Mar 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Uninitialized variables

    Can someone help clear things up for me here. I talked with Freedy about SCAR. He said he is currently using Delphi 7 with a script engine and creating a thread to launch the script in. Now I know from experience and Freedy agreed that variables do not get magically initialized to any particular value.
    As you can see from my "Chicken" status that I am just a noob at SRL so I am assuming there is something I don't know about here but a lot of the code I have been looking at in the SRL library uses variables that are never initialized.
    I copied and pasted some code below from the logout method.
    You will notice that the local variable "c" is never initialized, so it could have a value of 83458736 as far as we know. Given that, you can see how the logic would not work i teajut happened to be something other than 0. This is just one of many examples I have run accross. I wrote a test program in delphi and attached a screen capture of the program window running in front of the source for the button click to demonstrate my point. I don't want to sound as if I am complaining because I am not. But I would like for either someone to explain to me how variables get initialized or we should begin going through all the existing code to fix these bugs. By the way these would be random because based on what other programs have run before you may get an unused area of memory or not so the values are completely unpredictable. I know some languages do initialize memory for you so I am assuming the developers are used to the other languages.

    Example:
    function Logout: Boolean;
    var
    c, i: Integer;
    begin
    Result := (not (LoggedIn));
    if Result = True then
    Exit;
    if GameTab(14) = False then
    Exit;
    Wait(200 + Random(100));
    while (LoggedIn) or (c < 10) do
    begin
    Inc(c);

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    In Scar, values are automatically initilaized as 0 on declaring them (if an integer or number value)
    Delphi doesn't have the built in auto 0 though, so if you do plan on Delphi coding, you will have to set to 0 to make sure it is 0.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Mar 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Are you sure Freddy told me there was nothing in SCAR to do that.? <confused> What would help me see for myself would be if I knew how to use the SCAR debugger. I quess I can just write some scripts to display the values of some vars to see what they are.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Uninitialized variables
    By NosePicker in forum OSR Help
    Replies: 3
    Last Post: 03-21-2008, 01:29 AM
  2. Variables
    By Jackrawl in forum OSR Help
    Replies: 4
    Last Post: 12-04-2007, 04:30 PM
  3. Variables..
    By doritoz in forum OSR Help
    Replies: 19
    Last Post: 09-03-2007, 03:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •