Home   Help Search Login Register  

Author Topic: Integer to String  (Read 554 times)

0 Members and 4 Guests are viewing this topic.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Integer to String
« on: 28 Oct 2004, 19:29:33 »
I want to convert an  integer number to a string.  

I hope someone will embarass me by show me how easy it is or that the function already exists.


Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Integer to String
« Reply #1 on: 28 Oct 2004, 19:39:53 »
_st = format["%1",_number]

_st will be the string value of _number

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Integer to String
« Reply #2 on: 28 Oct 2004, 19:53:14 »
Thanks.  I thought I had tried that.  I was prepared to be happily embarassed but unfortunately if:
_number = 12345678 then the string returned is "1.23457e+007" and not "12345678"

I have now written my own code to do it (it only works for 8 digits though.  Does anyone know the highest object number on any of the maps?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Integer to String
« Reply #3 on: 28 Oct 2004, 20:02:24 »
Let me see now.........

Abel....... 103,114
Cain....... 70,770
Eden....... 56,740
Intro....... 0
Noe ....... 177,224


And there you have it.



Planck
I know a little about a lot, and a lot about a little.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Integer to String
« Reply #4 on: 28 Oct 2004, 20:11:22 »
EDIT2
Never mind ::)

EDIT:
Thanks.  I thought I had tried that.  I was prepared to be happily embarassed but unfortunately if:
_number = 12345678 then the string returned is "1.23457e+007" and not "12345678"

I have now written my own code to do it (it only works for 8 digits though.  Does anyone know the highest object number on any of the maps?
Well, OFP uses only six digits, so that's the problem...
(I think I told you this at the object thread (??)... Altough the example I gave was utterly wrong... ::) )
But, a value can not be more than 999999, otherwise it goes 'bananas'...
« Last Edit: 28 Oct 2004, 20:15:25 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Integer to String
« Reply #5 on: 28 Oct 2004, 20:53:21 »
Thanks.  So I could have used Raptorsaurus' method after all.  Ah well, I needn't have writtren my own script.  In fact I have now changed my script to use Raptorsaurus' method.

Plank:  Thanks - how did you do that?  
« Last Edit: 28 Oct 2004, 21:02:05 by THobson »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Integer to String
« Reply #6 on: 28 Oct 2004, 22:07:23 »
Quote
Plank:  Thanks - how did you do that?

Simple, I loaded each island into WrpEdit, then I used WrpEdit to find out the total number of objects on each island.

Skinning cats you know........    ::)


Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Integer to String
« Reply #7 on: 28 Oct 2004, 22:13:04 »
Neat.  But what if there are gaps in the object numbers - or does that not happen?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Integer to String
« Reply #8 on: 28 Oct 2004, 22:31:09 »
There shouldn't be any gaps in the number sequence.

Every time an island is saved the objects are effectively renumbered, at least that is the way I understand it.



Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Integer to String
« Reply #9 on: 28 Oct 2004, 22:36:53 »
Well that would make sense.

I will have to look at WrpEdit

Thanks for the tip.