| Home | Downloads | What is a "HovpoH", anyway? | Klingon Calendar System | HovpoH Timeline | Sign our guestbook! | View our guestbook! | Links |
| Conversions | |||
|---|---|---|---|
| Convert calendar date | Convert HovpoH | Convert Klingon Calendar Date | Convert SuStel's Stardate |
| Time-Wasters | ||||
|---|---|---|---|---|
|
wa' cha' wa'maH The Warrior's Game |
Klingon Magic 8 Ball | E-Mail Signature Generator |
Dove® Wrapper Translation Project |
{var'aq} |
This page is here to share some of the code I've created while learning {var'aq}.
If you've never heard of {var'aq}, I suggest you visit The var'aq Programming Language Homepage and my varaq main page before going any further.
If you know what {var'aq} is, and want some beginner-level information on it, stop by my {var'aq} tutorial page for a good graounding to get you started.
Spare as {var'aq} is, there is still a surprising amount of things that can be done with it.
If you are unfamiliar with var'aq programming, and you need some help getting started, this tutorial should get you off to a good start.
Below is a listing of the code I've authored.
Lucky 6
Warp Factor
Soapmaker
getAt()
indexOf()
makeReverse()
{wa' cha' wa'maH}
HovpoH
Calendar Date
Lucky 6
This function will choose six random numbers for you.
One of my first efforts, this brings new meaning to the word "trivial".
Then call it.
Do'

Warp Factor
This function will convert a warp factor into more familiar units.
(* The math gets messy below 1 and over 9.6 *)
latlh 1 puS'a' { woD 1 } HIja'chugh
latlh 9.6 law''a' { woD 9.6 } HIja'chugh
(* Present input *)
latlh
"Warp Factor " tam
tlheghrar cha'
"equals" cha'
(* Conversion from warp to absolute speed *)
latlh
10 3 boqHa''egh
boq'eghqa'
tam
10 tam
boqHa'
-11 3 boqHa''egh
boq'eghqa'
boq
(* Round to the tenths place *)
10 boq'egh
Hab
10 boqHa''egh
(* Display as factor of c *)
latlh
" times the speed of light"
tlheghrar cha'
"or" cha'
(* Convert to km/s *)
299792.458 boq'egh
(* Round *)
10 boq'egh
Hab
10 boqHa''egh
(* Display as km/s *)
" km/s"
tlheghrar cha'
} pong
Then enter:
4 pIvlob

Soapmaker
Another of my hobbies is soapmaking. The soaps I make at home are higher-quality than commercial soaps, not to mention cheaper.
Unfortunately, many soapmaking newbies are intimidated by the math involved. If you mess up your calculations, you could either wind up with a hunk of grease or a block of lye.
Not good, to say the least.
So I created these two functions to ease things along.
(* Convert grams of oil into grams of KOH *)
1000 boqHa''egh
boq'egh
(* Convert g of KOH to g of NaOH *)
40 56.1 boqHa''egh
boq'egh
(* Round to .01 grams *)
100 boq'egh
Hab
100 boqHa''egh
(* Present output for oil component *)
latlh
"NaOH needed for oil: " tam
tlheghrar cha'
(* Add to running total *)
boq
(* Round *)
100 boq'egh
Hab
100 boqHa''egh
(* Present total so far *)
latlh
"NaOH needed for total blend: " tam
tlheghrar cha'
} pong
lI'moH disc { (* Discount *)
(* Convert discount percentage to factor of total oils *)
100 tam
boqHa'
100 boqHa''egh
boq'egh
(* Round *)
100 boq'egh
Hab
100 boqHa''egh
(* Display for user *)
"After discount: " tam
tlheghrar cha'
} pong
Care and feeding
In order to use this program, you must know three things:
Call it like this:
[SAP value] [Weight of oil component, in grams] g
Repeat until all oils are entered.
Then:
[Discount percentage] disc
The output will indicate the proper amount of Sodium Hydroxide to use.
Let's do a trial run, shall we?
You have a soap recipe that calls for 1 kg of Beef Tallow, and 500 g of Coconut Oil, with a five percent discount.
Looking at a SAP value chart, we find that Beef Tallow has a value of 197, and Coconut Oil is a good 268. So, we begin entering oils:
197 1000 g
That's a SAP value of 197, 1000 grams (1 kg) of oil.
The output will look like this:
NaOH needed for oil: 140.46
NaOH needed for total blend: 140.46
Then we enter our next oil:
268 500 g
Output:
NaOH needed for oil: 95.54
NaOH needed for total blend: 236
Now we figure the discount:
5 disc
Output:
After discount: 224.2
This is the weight, in grams, of the NaOH needed to make your soap.

getAt()
As many have probably guessed, my favorite web "language" is JavaScript.
One of the more useful functions is the "String::getAt()" function, which will return the character found at the passed zero-based index.
var string=new String;
string="Klingon";
var ch=string.getAt(4);
In {var'aq}, however, string handling is something of a "black art", and it does not have a "getAt()"-type function in the spec, so I made one:
Call it like this:
"Klingon" 4 Daq_Suq

indexOf()
Another useful function in JS is the "String::indexOf" function.
var string=new String;
string="Klingon";
var ind=string.indexOf('g');
lI'moH tlheghDaq_nej { (* "SeekInString" *)
Degh (* char to look for *)
tlhegh patlh Daq_Suq (* get char for comparison *)
(* if char's don't match, prepare to get next rank *)
tlheghrap'a' { patlh wa'boq "patlh" cher } ghobe'chugh
wa'boq (* increment counter *)
(* if counter is less than string length, do it again *)
latlh
tlhegh tlheghjuv puS'a' { tlheghDaq_nej } HIja'chugh
} pong
Call it like this:
"Klingon" "g" patlh_Suq
Be sure when you enter the above code, you include Daq_Suq.

makeReverse()
Yet another JavaScript emulation.
var string=new String;
string="Klingon";
string.makeReverse();
"str" cher (* Could not do this without a "global" Sorry *)
qaw (* Used for making all one string at the end *)
str tlheghjuv (* Decrementing counter *)
latlh { (* used as parameter for vangqa' *)
wa'boqHa' (* Decrement counter *)
latlh (* Parameter for Daq_Suq *)
str tam (* proper order for upcoming Daq_Suq *)
(* Cannot call Daq_Suq from vangqa' loop *)
latlh wa'boq tlheghpe'
(* char goes behind counter *)
tam
} vangqa'
woD (* Throw away counter, no longer needed *)
naQmoH (* all one string, and leave it on top of the stack *)
} pong
Call it like this:
"Klingon" neSlo'
So, 0123456789 neSlo' will get you 987654321, without the zero.

1, 2, 10 The Warrior's Game
This is a var'aq implementation of {wa' cha' wa'maH}.
0 "total" cher (* Set total to zero *)
(* Flip a coin to see who goes first *)
100 mIS
50 law'rap'a' wIv
{ "You go first" cha' yIruch } HIja'chugh
{ "I'll go first" cha' ruch_De'wI' } ghobe'chugh
} pong
lI'moH mI'_Suq { (* "getNumber" *)
(* Choose a number based on total *)
total 0 rap'a' { 1 } HIja'chugh
total 1 rap'a' { 2 } HIja'chugh
total 2 rap'a' { 2 } HIja'chugh
total 3 rap'a' { 1 } HIja'chugh
total 4 rap'a' { 1 } HIja'chugh
total 5 rap'a' { 2 } HIja'chugh
total 6 rap'a' { 1 } HIja'chugh
total 7 rap'a' { 2 } HIja'chugh
total 8 rap'a' { 2 } HIja'chugh
total 9 rap'a' { 1 } HIja'chugh
total 10 law'rap'a' { 0 } HIja'chugh
} pong
lI'moH yIruch { (* You go *)
(* Get input from user *)
"Please enter 1 or 2" cha'
'Ij
(* Present input back to user *)
latlh
"Your number: " tam
tlheghrar cha'
total boq "total" cher (* Add to total *)
(* Display total to user *)
"Total: " total
tlheghrar cha'
(* Check to see of anyone's won *)
total 10 law'rap'a' wIv
(* If you did, congratulate *)
{ "You win!" cha' } HIja'chugh
(* If not, let the comp take a crack at it *)
{ ruch_De'wI' } ghobe'chugh
} pong
lI'moH ruch_De'wI' { (* The comp goes *)
(* Get number, display for user *)
mI'_Suq
latlh
"My number: " tam
tlheghrar cha'
total boq "total" cher (* Add to total *)
(* Display total to user *)
"Total: " total
tlheghrar cha'
(* Check to see if anyone's won *)
total 10 law'rap'a' wIv
(* If the comp won, it will tell you *)
{ "You lose!" cha' } HIja'chugh
(* If not, ball's in user's court *)
{ yIruch } ghobe'chugh
} pong
Then call it:
wcwm

HovpoH
This function will display the current HovpoH.
(* Conversion from secs since epoch to HovpoH *)
34714051200 boq
21038.9770519 boqHa''egh
1000000 boqHa'
(* Truncate to one decimal place*)
10 boq'egh
poD
10 boqHa''egh
tlheghrar (* turn them into one string and *)
cha' (* show it *)
} pong
Call it thusly:
HovpoH

Calendar Date
These functions will display the current date and time in Greenwich, England.
31536000 (* Seconds in normal year *)
(* If it's a leap year, add 1 day *)
DIS 4 chuv 0 rap'a' { 86400 boq } HIja'chugh
} pong
lI'moH jar_lup_Suq { (* "GetSecInMonth" *)
(* Choose based on month on question *)
jar 1 rap'a' { 2678400 } HIja'chugh
jar 2 rap'a' {
2419200
(* If it's Feb of a leap year, add one day *)
DIS 4 chuv 0 rap'a' { 86400 boq } HIja'chugh
} HIja'chugh
jar 3 rap'a' { 2678400 } HIja'chugh
jar 4 rap'a' { 2592000 } HIja'chugh
jar 5 rap'a' { 2678400 } HIja'chugh
jar 6 rap'a' { 2592000 } HIja'chugh
jar 7 rap'a' { 2678400 } HIja'chugh
jar 8 rap'a' { 2678400 } HIja'chugh
jar 9 rap'a' { 2592000 } HIja'chugh
jar 10 rap'a' { 2678400 } HIja'chugh
jar 11 rap'a' { 2592000 } HIja'chugh
jar 12 rap'a' { 2678400 } HIja'chugh
} pong
lI'moH DIS_Suq { (* "GetYear" *)
(* Subtract SecInYear from total sec *)
lup DIS_lup_Suq boqHa' "lup" cher
DIS wa'boq "DIS" cher (* Increment year *)
(* If there's a year's seconds left, do it again *)
lup DIS_lup_Suq law'rap'a' { DIS_Suq } HIja'chugh
} pong
lI'moH jar_Suq { (* "GetMonth" *)
(* Subtract SecInMonth from total sec *)
lup jar_lup_Suq boqHa' "lup" cher
jar wa'boq "jar" cher (* Increment month *)
(* If there's a month's seconds left, do it again *)
lup jar_lup_Suq law'rap'a' { jar_Suq } HIja'chugh
} pong
lI'moH jaj_Suq { (* "GetDay" *)
(* Get number of whole days *)
lup 86400 boqHa''egh poD "jaj" cher
(* Subtract that many seconds from total *)
lup 86400 jaj boq'egh boqHa' "lup" cher
(* Increment, because there is no day zero *)
jaj wa'boq "jaj" cher
} pong
lI'moH rep_Suq { (* "GetHour" *)
(* Get number of whole hours *)
lup 3600 boqHa''egh poD "rep" cher
(* Subtract it from total seconds *)
lup 3600 rep boq'egh boqHa' "lup" cher
} pong
lI'moH tup_Suq { (* "GetMinute" *)
(* Get number of whole minutes *)
lup 60 boqHa''egh poD "tup" cher
(* Subtract it from total sec *)
lup 60 tup boq'egh boqHa' "lup" cher
} pong
lI'moH DaH { (* "Now" *)
(* Initialize variables *)
1970 "DIS" cher
1 "jar" cher
(* Set number of seconds to current time *)
poH "lup" cher
(* GetYear *)
DIS_Suq
(* Have we had at least one whole month yet this year? *)
lup jar_lup_Suq law'rap'a' { jar_Suq } HIja'chugh
(* Get Day, Hour and Minute *)
jaj_Suq
rep_Suq
tup_Suq
(* Less than 10 minutes or secs? Slap a zero in front of it *)
tup 10 puS'a' { "0" tup tlheghrar "tup" cher } HIja'chugh
lup 10 puS'a' { "0" lup tlheghrar "lup" cher } HIja'chugh
(* Present output to user *)
jar "/" jaj "/" DIS tlheghrar tlheghrar cha'
rep ":" tup ":" lup tlheghrar tlheghrar cha'
} pong
And call it:
DaH
Output as of this writing (HovpoH 700577.0) will look like this:
9/23/2003
21:08:32
Here's another way to send me e-mail!
Klingon™ is a trademark of Paramount, Inc. No infringement is intended.
This page is best viewed at a 800x600 resolution or higher
©2003 De'wI' joH'a'