Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Integer Conversion problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tjmoore1993




PostPosted: Sat May 02, 2009 5:18 pm   Post subject: Integer Conversion problem

What is it you are trying to achieve?
I want my converted value you equal the original value before conversion.


What is the problem you are having?
When I convert my integer to a string I get an unequal value.
Example:
INT Value : 100
STRING VALUE : 236

Describe what you have tried to solve this problem
I know that my problem has to do with base but I do not understand it as much.

Turing:

    Damagex := 250
    Damagey := 240
    if cAccuracy > mAccuracy_1 then
        RedDamage := (intstr (cDamage, 0, 8))  % Problem is here. Base is where the value 8 is. I do not understand it as much but if I can get help I'd appreciate it.
        for i : 1 .. length (RedDamage)
            if RedDamage (i) = "0" then
                Pic.Draw (NoRed0, Damagex, Damagey, picMerge)
                Damagex := Damagex + 25
            elsif RedDamage (i) = "1" then
                Pic.Draw (NoRed1, Damagex, Damagey, picMerge)
                Damagex := Damagex + 16
            elsif RedDamage (i) = "2" then
                Pic.Draw (NoRed2, Damagex, Damagey, picMerge)
                Damagex := Damagex + 23
            elsif RedDamage (i) = "3" then
                Pic.Draw (NoRed3, Damagex, Damagey, picMerge)
                Damagex := Damagex + 21
            elsif RedDamage (i) = "4" then
                Pic.Draw (NoRed4, Damagex, Damagey, picMerge)
                Damagex := Damagex + 25
            elsif RedDamage (i) = "5" then
                Pic.Draw (NoRed5, Damagex, Damagey, picMerge)
                Damagex := Damagex + 22
            elsif RedDamage (i) = "6" then
                Pic.Draw (NoRed6, Damagex, Damagey, picMerge)
                Damagex := Damagex + 25
            elsif RedDamage (i) = "7" then
                Pic.Draw (NoRed7, Damagex, Damagey, picMerge)
                Damagex := Damagex + 22
            elsif RedDamage (i) = "8" then
                Pic.Draw (NoRed8, Damagex, Damagey, picMerge)
                Damagex := Damagex + 22
            elsif RedDamage (i) = "9" then
                Pic.Draw (NoRed9, Damagex, Damagey, picMerge)
                Damagex := Damagex + 25
            end if
        end for
    else
        Pic.Draw (NoRedMiss, Damagex - 25, Damagey, picMerge)
    end if
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Sat May 02, 2009 6:39 pm   Post subject: Re: Integer Conversion problem

There is no need to have the 0 or the 8 in the intstr call. The 0 refers to the width of the string, so it is probably doing nothing. The 8 means that it will output the numbers in base 8. you probably do not want base 8.

simplify it by just using intstr(value) with no extra parameters. the other parameters are optional, the command will still work if you leave them out.

Turing:

var myString : string
var base8 : string

myString := intstr(100)
put myString
base8 := intstr(100,0,8)
put base8


myString returns 100, base8 returns 144.
tjmoore1993




PostPosted: Sat May 02, 2009 7:07 pm   Post subject: RE:Integer Conversion problem

Thanks, I haven't actually thought about it that way. I totally forgot I can leave out parameters. Thanks for the help Smile!
Dusk Eagle




PostPosted: Sat May 02, 2009 8:45 pm   Post subject: Re: Integer Conversion problem

Your NoRed0,1,2 etc. variables would be much better if stored in an array. Then, you could replicate your for loop in much shorter lines:
Turing:

for i : 1 .. length (RedDamage)
    for j : 0 .. 9
        if RedDamage (i) = intstr(j) then
            Pic.Draw (NoRed(j), Damagex, Damagey, picMerge)
            if j = 0 or j = 6 or j = 9 then
                Damagex += 25
            elsif %fill in yourself
            end if
        end if
    end for
end for
tjmoore1993




PostPosted: Sun May 03, 2009 10:44 am   Post subject: Re: Integer Conversion problem

Dusk Eagle @ Sat May 02, 2009 8:45 pm wrote:
Your NoRed0,1,2 etc. variables would be much better if stored in an array. Then, you could replicate your for loop in much shorter lines:
Turing:

for i : 1 .. length (RedDamage)
    for j : 0 .. 9
        if RedDamage (i) = intstr(j) then
            Pic.Draw (NoRed(j), Damagex, Damagey, picMerge)
            if j = 0 or j = 6 or j = 9 then
                Damagex += 25
            elsif %fill in yourself
            end if
        end if
    end for
end for



Works :
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Dusk Eagle




PostPosted: Sun May 03, 2009 12:02 pm   Post subject: Re: Integer Conversion problem

Those pictures actually look pretty good there. Did you make them?
tjmoore1993




PostPosted: Sun May 03, 2009 1:15 pm   Post subject: Re: Integer Conversion problem

Dusk Eagle @ Sun May 03, 2009 12:02 pm wrote:
Those pictures actually look pretty good there. Did you make them?


I did not make the ground or characters. They were extracted from Maplestory's WZ archive.
Most of the artwork though is mine. Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: