www.ClassicTW.com http://www.classictw.com/ 

TWX Proxy  Asignment Operators http://www.classictw.com/viewtopic.php?f=15&t=35638 
Page 1 of 1 
Author:  Micro [ Mon Dec 30, 2019 2:21 pm ] 
Post subject:  TWX Proxy  Asignment Operators 
ok, since no one requested anything, I worked on one of my own requests: TWX doesn't have an assignment operator, well is has: Code: setvar $puke true ... but wouldn't it be nice if you could use ":=" instead? Code: $puke := false ok, I still want to put a ; at the end of that, but isn't that a lot easier to read? and wouldn't it be nice if you could use "*=", "/=", "+=", "=", "++", and "" operators like this: Code: $dogs := 11 While $birds < 5 $birds++ $mice += 2 * $birds $dogs = 2 echo "Your cats ate " $birds " birds and " $mice " mice, and chased " $dogs " dogs*" end $dogs := 5 $cats := 1 while $dogs > 0 $feline := $cats * 100 $feline /= $cats + $dogs echo "You Have " $dogs " Dogs and " $cats " Cats, which is " $feline "% feline*" $Dogs $cats *= 2 end Well, i just finished writing this feature, and here is the output of the above script: Code: Your cats ate 1 birds and 2 mice, and chased 9 dogs Your cats ate 2 birds and 6 mice, and chased 7 dogs Your cats ate 3 birds and 12 mice, and chased 5 dogs Your cats ate 4 birds and 20 mice, and chased 3 dogs Your cats ate 5 birds and 30 mice, and chased 1 dogs You Have 5 Dogs and 1 Cats, which is 16% feline You Have 4 Dogs and 2 Cats, which is 33% feline You Have 3 Dogs and 4 Cats, which is 57% feline You Have 2 Dogs and 8 Cats, which is 80% feline You Have 1 Dogs and 16 Cats, which is 94% feline I think I managed to get all 7 new mathematical operators in there, and used a few of the old operators that most people forget were added in TWX 2.0. It is just a bit of compiler fakery, as it is still using setvar, add, multiple, etc... internally... but I think it is so much easier to read when using assignment operators instead of functions. don't you? 
Author:  Hammer_2 [ Thu Jan 09, 2020 6:49 am ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Very nice Micro, I think I eluded to wanting something like this months (years?) ago. I may get back into the game at some point and will surely appreciate your efforts. 
Author:  Cruncher [ Thu Jan 09, 2020 8:23 am ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Missing Modulus % But, I don't know if the % symbol is recognizable for TWXProxy and have been thinking of when it may be applicable to a script. Just something I ponder. 
Author:  Micro [ Thu Jan 09, 2020 12:21 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
It is not the only operator missing: Modulus is the remainder of a division operation. 10 / 4 = 2.5 10 % 4 = 5 Sounds like something an accountant would use. I might add it as it is the only "Arithmetic" operator missing. Maybe it would come in handy in a haggling routine? 
Author:  Cruncher [ Thu Jan 09, 2020 6:07 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Micro wrote: It is not the only operator missing: Modulus is the remainder of a division operation. 10 / 4 = 2.5 10 % 4 = 5 Sounds like something an accountant would use. I might add it as it is the only "Arithmetic" operator missing. Maybe it would come in handy in a haggling routine? No, I actually learned about that when I went back to learn programming. Maybe EP could use it for his haggle? 
Author:  Micro [ Thu Jan 09, 2020 7:07 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Cruncher wrote: Maybe EP could use it for his haggle? I know he uses floating point math in EP haggle, so I am not sure. 
Author:  Hammer_2 [ Thu Jan 09, 2020 7:19 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Micro wrote: Cruncher wrote: Maybe EP could use it for his haggle? I know he uses floating point math in EP haggle, so I am not sure. If this is some tricky way to expose how his haggling routine actually works.. then well played! 
Author:  Micro [ Thu Jan 09, 2020 8:41 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Hammer_2 wrote: If this is some tricky way to expose how his haggling routine actually works.. then well played! No I haven't looked at the code. 
Author:  Cruncher [ Thu Jan 09, 2020 11:17 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Micro wrote: Hammer_2 wrote: If this is some tricky way to expose how his haggling routine actually works.. then well played! No I haven't looked at the code. Well... it floats the wrong way sometimes, maybe he does need Modulus 
Author:  Shadow [ Fri Jan 10, 2020 11:24 am ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Hammer_2 wrote: Micro wrote: Cruncher wrote: Maybe EP could use it for his haggle? I know he uses floating point math in EP haggle, so I am not sure. If this is some tricky way to expose how his haggling routine actually works.. then well played! Pretty much everyone knows how it works now. The source code is out there. 
Author:  ElderProphet [ Mon Jan 13, 2020 7:55 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Nice work Micro! +EP+ 
Author:  Micro [ Tue Jan 14, 2020 12:15 pm ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
ElderProphet wrote: Nice work Micro! +EP+ Thanks, That means a lot coming from you! 
Author:  Micro [ Wed Jul 01, 2020 11:04 am ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Cruncher wrote: Missing Modulus %. I added the modulus command and operator, and I already found a use for it when writing the new performance timer commands: Code: StartTimer $Timer1 # Do something that may take a while StopTimer $Timer1 $Seconds := $Timer1 / 1000 $MiliSec := $Timer1 % 1000 Echo "You command took " $Seconds " seconds and " $MiliSec " ms to complete." In this example "$Timer1 % 1000" returns the number of ms elpased. 
Author:  Cruncher [ Wed Jul 01, 2020 11:40 am ] 
Post subject:  Re: TWX Proxy  Asignment Operators 
Micro wrote: Cruncher wrote: Missing Modulus %. I added the modulus command and operator, and I already found a use for it when writing the new performance timer commands: Code: StartTimer $Timer1 # Do something that may take a while StopTimer $Timer1 $Seconds := $Timer1 / 1000 $MiliSec := $Timer1 % 1000 Echo "You command took " $Seconds " seconds and " $MiliSec " ms to complete." In this example "$Timer1 % 1000" returns the number of ms elpased. Nice! 
Page 1 of 1  All times are UTC  5 hours 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ 