Page 4 of 6 « First<23456>
Topic Options
#66630 - 2002-06-11 06:42 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Okay.. I'll post it.. see if you can get it smaller and test it to make sure no bugs! [Smile] It's hard to believe that after the original 261, it could be shaved to 231, but here it is:

code:
Function BaseConverter($v,$f,$t)
$=len($v)
$n=0
$y=1.
Do
$x = ASC(UCASE(substr($v,$,1)))
$n=$y*($x - 48 - ($x > 64) * 7) +$n
$y=$y*$f
$=$-1
Until $=0

$=""
While $n
$x = INT($n - (INT($n/$t) * $t))
$n = ($n-$x)/$t
$ = CHR($x + 48 + ($x > 9) * 7) + $
Loop
$BaseConverter = $
Endfunction

Enjoy!

Brian

[ 11 June 2002, 19:17: Message edited by: BrianTX ]

Top
#66631 - 2002-06-11 06:49 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, at the expense of a few cycles, you could probably shave a stroke by:

Removing this line initializer:

$n=0

an editing this line like so ( add 0. at beginning):

$n = 0. + $y * ($x - 48 - ($x > 64) * 7) + $n

hmmm,

Top
#66632 - 2002-06-11 06:51 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Perhaps, Shawn, but the idea is for it to work if someone already has a $n variable in their script.

Brian
{edit} it should work the same without the 0. ... because $y is the first thing evaluated and is type double. ... I included the $n = 0 so that this script would work even if there was a stray $n somewhere. Of course, theoretically, if someone has a stray $n somewhere, it would get overwritten and cause a problem anyway... so maybe Jens should rule on this?

[ 11 June 2002, 18:55: Message edited by: BrianTX ]

Top
#66633 - 2002-06-11 07:00 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Like I said before, imho, I think all vars should be local and dimmed (self-contained). This will tend to penalize scripts that have lots of vars - but maybe thats a good thing too.

Plus, if you use the $ thingy, that should be dimmed as well. Not sure if that works though - singleton $ might be a funky global var. Should test it I guess.

I think I've learned more about The KiXtart Scripting Language in this one Golf Tournie, than I have in months on the board here.

{edit} Rephrased my first sentence.

[ 11 June 2002, 19:03: Message edited by: Shawn ]

Top
#66634 - 2002-06-11 07:13 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
And I thought I didn't have a life... [Razz]

[ 11 June 2002, 19:14: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66635 - 2002-06-11 07:19 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Lol.. well, this is certainly interesting.. teaches a lot about how KiXtart works..especially with handling of numerical types -- try as I might, I am unable to simplify the modulo algorithm..(and get it to work).

As for DIMming variables.. if a variable is declared explicitly (on the bases of other declared variables or constants), it shouldn't need a DIM should it?

Brian

[ 11 June 2002, 19:20: Message edited by: BrianTX ]

Top
#66636 - 2002-06-11 07:24 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not at least on kixgolf according to rules.
_________________________
!

download KiXnet

Top
#66637 - 2002-06-11 07:39 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Brian, your right. They don't need to be dimmed (eg, for the function to work properly) - I propose that they should be dimmed - strickly from a philosophical zen standpoint (or in KiXspeak - would that be Xen?) [Wink]
Top
#66638 - 2002-06-11 07:43 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Brian, here's one I tried but have not yet found a place to utilize it yet:

$x=$y=3

This sets the value of $x to 0 or 1 depending on the value of $y.

[ 11 June 2002, 19:56: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66639 - 2002-06-11 07:53 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I like how that works.. I was thinking as I was fiddling around with this, that at some point, it might be nice to have a NOR, SQRT, XOR, ^, log, e, and ln functions in KiXtart... although this is only a wish list for THIS type of problem.

Brian

Top
#66640 - 2002-06-11 08:05 PM Re: Round 2: KiXtart Golf Tournament Part III
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Nice one Howard,

It seems like KiX evaluates this statement:
$x=$y=3

As True ($x=1) if $y = 3

AS False ($x =0) if $y<>3

I just tested the Vartype of $x after executing the line, i had hoped it would be Boolean, it could then have acted as typecasting a var to boolean, but the type is Long.

Anyway $x can still be evaluted as false/true later in the script.

Remember this, it could be usefull on the next KixGolf course.

-Erik

Top
#66641 - 2002-06-11 08:10 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I agree. Some more bitwise operators would be helpful in more than just this issue. Exponents and roots should be included with basic mathmatical operators.

I guess we just want Kix to be more than something to use when mapping a drive.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66642 - 2002-06-11 08:25 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Or, you can tell if a number is odd:
$x = 324152
....
$y = $x&1
$y = $x MOD 2

Or if it is even:
$y = NOT ($x&1)
$y = NOT ($x MOD 2)
$y = $x + 1 & 1

Brian

Top
#66643 - 2002-06-11 08:28 PM Re: Round 2: KiXtart Golf Tournament Part III
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Another usefull statement could be:

$x=Not $x

This will invert the value of a boolean value, from 0 to 1 or 1 to 0

When executed on a number <> 0, it returns 0
When executed on a not defined variable, it returns 1
When executed on an empty string, it returns 1
When executed on a string, it returns 0

-Erik

Edited by request from BrianTX [Embarrassed]
Original post stated:
When executed on a number <> 0, it returns 1

[ 12 June 2002, 00:11: Message edited by: kholm ]

Top
#66644 - 2002-06-11 08:31 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Actually if it's executed on a number <> 0 it returns 0.

$x = 2343
$x = not $x
$x ?

You get 0.

Brian

Top
#66645 - 2002-06-11 09:11 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
these should be documented somehow.
we are getting so many syntax tricking ways that I can't keep up any longer...
_________________________
!

download KiXnet

Top
#66646 - 2002-06-11 09:15 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Yeah.. we could get together and write a manual on ways to manipulate kixtart, loops, operators, expressions, output, etc.

Brian

Top
#66647 - 2002-06-11 09:27 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sounds like a paperback book. $4.95US please [Wink]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66648 - 2002-06-11 10:03 PM Re: Round 2: KiXtart Golf Tournament Part III
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Sometimes the answer is shining in your eyes [Smile]

Create a Boolean type variable

Testscript:
code:
$x = Not 1
? $x
? VarTypeName($x)
Get $y

$x is now a var of type Boolean, could be usefull in COM-scripting ?

-Erik

Top
#66649 - 2002-06-11 10:38 PM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
guys,
could you try it purely...
I don't have win machines currently running here at my own vpn so can't try out...

does it error out if used without 1.
like:
$x = NOT
?
_________________________
!

download KiXnet

Top
Page 4 of 6 « First<23456>


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

Who's Online
0 registered and 165 anonymous users online.
Newest Members
MaikSimon, kvn317, kixtarts2025, SERoyalty, mytar
17872 Registered Users

Generated in 0.075 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

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