#66630 - 2002-06-11 06:42 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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! 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
|
|
|
|
#66632 - 2002-06-11 06:51 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66634 - 2002-06-11 07:13 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
And I thought I didn't have a life... [ 11 June 2002, 19:14: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#66635 - 2002-06-11 07:19 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66637 - 2002-06-11 07:39 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Shawn
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?)
|
Top
|
|
|
|
#66638 - 2002-06-11 07:43 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Howard Bullock
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 ]
|
Top
|
|
|
|
#66639 - 2002-06-11 07:53 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66641 - 2002-06-11 08:10 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Howard Bullock
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.
|
Top
|
|
|
|
#66642 - 2002-06-11 08:25 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
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 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
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
|
|
|
|
#66646 - 2002-06-11 09:15 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Sounds like a paperback book. $4.95US please
|
Top
|
|
|
|
#66648 - 2002-06-11 10:03 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Sometimes the answer is shining in your eyes
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 239 anonymous users online.
|
|
|