IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 How to convert integer variable to string?

 Opcode requires string, I have integer
 
fastman92  
Posted: Monday, Oct 4 2010, 18:21
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



CODE
0AF0: 8@ = get_int_from_ini_file "CarSpawnerRanges.ini" section "1" key "start"

It works, when parameter for section is string.

CODE
0AF0: 8@ = get_int_from_ini_file "CarSpawnerRanges.ini" section 7@ key "start"

My 7@ is integer.
Executing this code causes crash, so how can I convert integer variable 7@ to any other string e.g 13@

This post has been edited by fastman92 on Monday, Oct 4 2010, 18:32
Users WebsitePMMSN
  Top
 

 
Wesser  
Posted: Monday, Oct 4 2010, 18:51
Quote Post


The complexity simplifier, the efficiency optimizer
Group Icon
Group: Members
Joined: Aug 19, 2006

eu.gif

Member Award




You have to make a lot of calculations to retrieve every integer unit and convert each one to string type. I've already done it since a while and it is a part of my CLEO3's SDK (still unreleased tounge2.gif):
CODE

{
 FUNCTIONS INCLUDED:

-   getPowVal
     Type: GET
       Description: Get the pow of an integer value.

-   getIntUnits
     Type: GET
       Description: Get all units of an integer value.

-   getIntUnit
     Type: GET
       Description: Get a specific unit of an integer value (from right).

-   convIntToStr
     Type: SET
       Description: Convert an integer value into a string.
}

{$CLEO}

0000: NOP

while true
 0AB1: call_scm_func @convIntToStr 1 num 65535 store_to 1@ 2@
 // 1@s will contain your value converted to string
end

:getPowVal
{
 Parameters:
   Passed:
     0@ - base
     1@ - exponent
   Result:
     2@ - integer/float

 Example:
   0AB1: call_scm_func @getPowVal 2 num 2 exp 3 store_to 0@
}
0085: 2@ = 0@
if
 1@ > 0
then
 for 3@ = 1 to 1@
   if
     3@ > 1
   then
     006A: 2@ *= 0@
   end
 end
else
 if
   1@ < 0
 then
   0093: 2@ = integer 2@ to_float
   0093: 0@ = integer 0@ to_float
   for 3@ = -1 to 1@
     if
       3@ < -1
     then
       006B: 2@ *= 0@
     end
   end
   4@ = 1.0
   0073: 4@ /= 2@
   0087: 2@ = 4@
 else
   2@ = 1
 end
end
0AB2: ret 1 2@

:getIntUnits
{
 Parameters:
   Passed:
     0@ - number
   Result:
     1@ - units -> 0 to 10

 Example:
   0AB1: call_scm_func @getIntUnits 1 num 125 store_to 0@
}
1@ = 0
0095: make 0@ absolute_integer
if
 0@ <> 0
then
 while 0@ > 0
   0@ /= 10
   1@ += 1
 end
else
 1@ = 1
end
0AB2: ret 1 1@

:getIntUnit
{
 Parameters:
   Passed:
     0@ - number
     1@ - unit position -> 0 to 10
   Result:
     0@ - unit

 Example:
   0AB1: call_scm_func @getIntUnit 2 num 125 unit 2 store_to 0@
}
0095: make 0@ absolute_integer
0AB1: call_scm_func @getIntUnits 1 num 0@ store_to 2@
if
002D:  2@ >= 1@
then
 0085: 3@ = 0@
 0AB1: call_scm_func @getPowVal 2 num 10 exp 1@ store_to 4@
 0072: 3@ /= 4@
 006A: 3@ *= 4@
 0062: 0@ -= 3@
 1@ -= 1
 0AB1: call_scm_func @getPowVal 2 num 10 exp 1@ store_to 4@
 0072: 0@ /= 4@
else
 0@ = 0
end
0AB2: ret 1 0@

:convIntToStr
{
 Parameters:
   Passed:
     0@ - number -> -9999999 to 9999999
   Result:
     2@/3@ - string value

 Example:
   0AB1: call_scm_func @convIntToStr 1 num 125 store_to 1@ 2@
}
if and
 0@ <=  9999999
 0@ >= -9999999
then
 0AB1: call_scm_func @getIntUnits 1 num 0@ store_to 1@
 if
   1@ > 7
 then
   1@ = 7
 end
 2@s = ''
 if
   0@ < 0
 then
   2@s = '-'
 end
 for 4@ = 1@ downto 1
   0AB1: call_scm_func @getIntUnit 2 num 0@ unit 4@ store_to 5@
   5@ += 0x30
   098B: 2@s = 2@s + 5@s
 end
end
0AB2: ret 2 2@ 3@
PMMSNPlayStation Network
  Top
 

 
fastman92  
Posted: Wednesday, Oct 6 2010, 18:21
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



Thanks Wesser!
Your function(s) works perfectly.
Users WebsitePMMSN
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG