Page 1 of 1 1
Topic Options
#39996 - 2003-05-12 05:05 AM reconvert
Anonymous
Unregistered


Hi there

is there a way I can reconvert $number2 back to a string?

$number=val($number2)

Top
#39997 - 2003-05-12 05:08 AM Re: reconvert
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
$number=''+$number
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#39998 - 2003-05-12 05:41 AM Re: reconvert
Anonymous
Unregistered


I am not sure that works....
Top
#39999 - 2003-05-12 05:51 AM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I am [Wink]
_________________________
!

download KiXnet

Top
#40000 - 2003-05-12 09:05 AM Re: reconvert
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Just for the case you use an actual release :



$string = cstr($integer

_________________________



Top
#40001 - 2003-05-12 09:16 AM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
j, what is actual release that you refer to?
_________________________
!

download KiXnet

Top
#40002 - 2003-05-12 10:27 AM Re: reconvert
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
well, at least 4.11 IIRC
_________________________



Top
#40003 - 2003-05-12 10:30 AM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
I thought that also betas and RC's work and you say that if one uses actual release? [Confused]

btw, even though it's nice to have a function to do the conversion, les' method is correct as well and as it's shorter, more used.
_________________________
!

download KiXnet

Top
#40004 - 2003-05-12 02:03 PM Re: reconvert
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Bonky,
I am sure it works.
code:
Break on
$number2 = "100"
'VarType ='+VarType($number2) ?
$number=val($number2)
'VarType ='+VarType($number) ?
$number=''+$number
'VarType ='+VarType($number) ?

quote:

VarType =8
VarType =3
VarType =8

C:\KiXScripts>

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#40005 - 2003-05-12 02:25 PM Re: reconvert
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I didn't say that Les' sample won't do, au contraire ...

I just wanted to show another way; Available since 4.10 btw. [Frown]
_________________________



Top
#40006 - 2003-05-12 02:27 PM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
j, just picking... just picking [Razz]
_________________________
!

download KiXnet

Top
#40007 - 2003-05-12 02:31 PM Re: reconvert
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Not to be too picky, but from the original question and code, $number2 never gets converted to a number, so it would not need to be converted back to string. [Wink]

code:
$number=val($number2)  

_________________________
Eric

Top
#40008 - 2003-05-12 02:34 PM Re: reconvert
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just to clean up a potential misunderstanding
code:
$number=''+$number

is using two (2) single quotes (') to delimit an emptyt string, not one (1) double quote (").Thus, three options would be
code:
$string=''+$number
$string=""+$number
$string=cstr($number)

. However, FORMATNUMBER() could also be used in certain cases.

[ 12. May 2003, 14:35: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#40009 - 2003-05-12 02:35 PM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, if you see it as whole script.
I thought anyway that it's just a part of something bigger [Wink]
_________________________
!

download KiXnet

Top
#40010 - 2003-05-12 02:40 PM Re: reconvert
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Just to be picky... [Wink]
I realized Bonky asked about reconverting $number2 but you will see in my code that I do not in fact do that.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#40011 - 2003-05-12 04:47 PM Re: reconvert
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Gentlemen,

Think we should stop that here and wait for Bonky to reply with his results [Razz]
_________________________



Top
#40012 - 2003-05-12 10:03 PM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think that's good idea, J!
_________________________
!

download KiXnet

Top
#40013 - 2003-05-13 08:09 AM Re: reconvert
Anonymous
Unregistered


Well!! what a topic I created!! [Eek!] well I managed to work this out with the input.. I manged to convert it to a string using...

while $count1 < 255 and $count2 < 111
shell "%COMSPEC% /e:1024 /c Del $testfile"
$statement = $site1+"."+$site2+"."+ $count2 +"."+$count1
shell "%COMSPEC% /e:1024 /c ping -a -n 1 -w 10 $statement >>$testfile"
gosub readit
$count1=$count1 + 1
loop

Top
#40014 - 2003-05-13 10:40 AM Re: reconvert
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
to explain a little:
$statement = $site1+"."+$site2+"."+ $count2 +"."+$count1

statement will come out as the first variable is pushed to it.
if your $site1 var is number, all the string variables are turned numbers (most likely lost)

if the first is then string, like now seems to be, all others are turned also to string.

that's how kix works.
but, you can force it either way:
$statement = ""+$site1+"."+$site2+"."+ $count2 +"."+$count1

gives you always string and:
$statement = 0+$site1+"."+$site2+"."+ $count2 +"."+$count1

gives you always integer.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.201 seconds in which 0.099 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org