Wednesday, June 30, 2010

Human civilisation across the history . . .

As I done a little bit of housekeeping, I accidentally stumbled one of my long hold forgotten possession of photocopied scrapbook assignments of Form 5 Sejarah. At that time, i did not have Computer much less the 56K Internet and no Google/Wikipedia for easy copying. :( [In my opinion, kids nowadays got very lucky ! ] so my assignment is purely done by referencing from many books in libraries writing on pieces of paper a.k.a hard copy.

P.S: The history assignment is originally done in BM so I directly translate into English here for sake of the readers who accidentally stumbles into this sites also PLEASE check out the facts before blindly copying these summary to your assignment , O.K ? If you do that, that is called plagiarism .

So below, is this the shortest summary of the entire human civilisation in the brief existence of hundred thousand years which is way more shorter compared to the Dinosaur period.

Prehistoric Ages
50,000 B.C - 5,000 B.C
It is first marked by when the pre-humans walked on this face on earth, started to live in communities (usually in caves) , using simplistic primitives tools a.k.a fixing sharpened stones to the sticks to make a spear which is known as hafting. In this ages  , the primitive humans also accidentally discovered fire that helped to cook food, melting irons, scare away large fierce animals and beasts and help keeps the cold away. It is probably estimated that the humans living in this ages are probably did not live of more than 40 years of age and which makes them aware of their own mortality. They indulged in shamanic practices, ancestor worship and rituals. As the society grows into a sizable communities from the hunters and foragers into different layers of society and more complex. This epoch ended by the singular centralized authority ( government ) and presence of hierarchical social structures.

Copper Age
5,000 B.C - 2,000B.C
It is first marked by when the human discovered metal such as copper, iron , gold and silver on the face on the earth.The copper is very prized due to its durability and malleability which means that copper is easily to be shaped into any different sizes and shape. Due to its properties, copper is widely used as coins which ends the barter trading system and mark an revolutionary beginning in currency trading and later the silver and gold were used due to their untarnished reputation. And also it is as preferred metal used in weapons smithing. In the recent archeological digging, the copper mace found dated to as far as from 3000 B.C. However, not all weapons are converted directly into copper usage such as bow and arrows. The arrows are still used widely because of its same lethality and stone ease of availability. Another milestones achieved in this epoch is the human discard nomadic lifestyle of hunting and gathering into permanent settlement lifestyle of farming agriculture. This is the main importance characteristic of an civilisation. The epoch ends when human starts to farming the crops and also the first traces of animal domestication activities can be found here in this epoch. The animals are usually reared for its meat and dairy products and also powered the tools used in farming. The first known civilisation is Sumeria civilisation in southern Mesopotamia in around 5,000 B.C.

Bronze Age
2,000 B.C - 0 A.D
The metallurgy field also expanded tremendously in this era as human maybe accidentally discovered the best portions of smelting bronze ( 1 part of tin : 10 parts of copper ). This discovery marks the triumph in metallurgy as the values of finding stronger metals were not lost among the ancient metal smiths. This epoch also features the sword as true weapons which does not have a secondary functions and also some interesting military formations used such as phalanx. Phalanx is the military tactics devised by Philip II of Macaedon whose son Alexander the Great is conquering much of the Asia Minor in their conquest campaigns. In this epoch, the wealthy prosperous cities are guarded with strong and improved fortifications made of sturdy granites and strong heavy woods. In counter effect, the invading army also devices new siege inventions such as battering ram by Assyrians, stone trebuchet catapult and siege towers by the Greeks. The first law created in the world, Code of Hammurabi were first legislated and enforced in Ancient Babylonian. Medicine practices also expanded tremendously within this era as the Hippocrates swears his own oath known as Hippocrates Oath which are basically the the thumb rule of medical practitioner must follow. Also it is in this time, the human understanding of the diseases is caused by bodily affliction to natural causes as compared to supernatural causes before the advances of the medicines practices. Besides the formal educations is the peak of this epoch achievement as where the nobles in Greece who had amount of wealth send their offspring to study philosophy, literacy, etiquette and other subjects as the roots of formal educations can be traced back to prestigious Academy founded by Plato in around 387BC. The epoch is ended by the fall of the Roman Empire.

Dark Ages
0 A.D - 900 A.D
The end of Roman Empires is the starts of this epoch. This era is also where weapon smith found that iron could supersede bronze in terms of their durability and weight. The Gothic Visigoth triumph over the Rome in the Battle of Adrianopole. The city of Rome were brought to ruins later in 410 A.D.  However, the Rome supremacy did not ended as the pockets of Romes civilisation exists under the shadows of mighty Rome Empire which is the Eastern Rome of Byzantines. It is here where the Emperor Constantinople legitimize the Christianity in 330 A.D as he convert to Christians allowing the Christianity to spread. It continues it reign in its power in 1000 years more before the fall. The Byzantine empire is a might in its own power as the naval armada improve sailing method by improvised lateen sails and the ballistic missiles which can transverse hundreds of meters over the enemies fortifications. On the land, however is another type of heavy calvary units of cataphract, well armed and heavily armoured calvary soldiers. On splintered Western Empire (Western Europe), the Emperor had tried to reunify the Roman Empires but due to conflict views of religious issues, Eastern Orthodox and Roman Catholics remained separated until to this day. The system ends with the rise of feudal system introduced across the land.

Middle Ages
900 A.D - 1300 A.D
The re-emergence of centralized authority and the technological advancement occurs in this era in a much more localized version. A local lord ruled a villages which are villages surrounded by high walls as the serfs is working on the land and armoured knight patrols the land and served in the lord's retinue. The well built castle were the ultimate defence mechanism at that period as the gun powder discovery lead to inventions of cannon which will make defence a bit more challenging. Therefore in this era, the architecture are expanding to make the castle much more tougher and invention of flying buttress  makes the cathedral more spacious. In this era, the Holy War between Islam and  Christians ravages across the holy sites including Jerusalem. There are total of 8 major Crusades launched to retake the Holy Land with few successful attempts but in no time, the Muslim warriors will retake it back.  However, in the home the first papal Inquisition is under the way to expose the heretics. Middle Ages ended as the Europe is undergoing Age of Enlightenment.

Renaissance
1300 A.D - 1500 A.D
The age of enlightenment is usually the epoch where the process of gradually recovering the past ancient knowledges in Europe.It literally means "rebirth". The first known Renaissance movement begins in Italy and swept across the Europe advocating the technological innovations and also the ways of thinking. A priest, Martin Luther find a innovations to the mass printing methods which leads to inventions of movable printing press and leads to mass products of books. As a result, the literacy rate increased more than ever as a preparation to the ages that are coming. The bubonic plague by name of Black Death is also forcing the reconstruction of sewers and garbage disposal system on very large scale that have not been undertook since fall of Roman Empire. The concept of quarantine is also introduced in this era which is basically controlling the spread of disease within an area.
. In firearm warfare,the early artillery pieces and firearms, such as the culverin and matchlock arquebus, began to appear on the battlefield.  Castles were easily breached by the new artillery and eventually became obsolete.  But early gunpowder weapons were unreliable, slow to load, and dangerous to operate.Thus, their superiority over more traditional forms of weaponry, such as the longbow, was not to be fully demonstrated until the 1600 A.D.

Imperial Age
1500 A.D - 1700 A.D
In this epoch, humans curiousity about the lands across the seas therefore the invention of large scale ships capable of navigating across the oceans marks the beginning of this epoch. In the quest of the conquering other nations, better designs of firearm were used. Flintlock musket which are faster to reload and cheaper to mass produce were replacing earlier version of  matchlock.   The era of archer is slowly meeting its demise as the firearms becomes more widespread. In 1688 , Napoleon army introduces bayonet that would actually replace the melee weapon all together. It is the revolution shift from medieval warfare transformed into modern warfare. The science in this era is going underway with its impressive achievements and the emphasis on empirically collected data and reproducible experiment results which marks the beginning of modern scientific method.

Industrial Age
1700 A.D - 1900 A.D
From the science revolution in Imperial Age, it had profound effect on the thinkings that science is the answer to everything. The scientific revolution also make a major breakthrough in civilisation. In medicine field, the discovery that the microbes pathogen are cause for many ailments lead to pasteurization and antiseptic inventions. Darwin theory of revolution with the Greoger Mendel works on genetic and hereditary makes an impact on deeper understanding of diversity of lives. Electricity had finally found its practical uses as electric batteries and generators were invented to perform all sorts of feat. Electricity also performs revolutionary trend in this era as it transform communication landscape from telegraph and telephone and also incandescent lamp bulb to replace gas lamp later in the turn of 1900 A.D.

Atomic Age 
1900 A.D - 2000 A.D
It is hard to decide when the atomic ages really started but the starting of World War I in a sense rapidly changing the modern warfare landscape. Many nations involved in the war in 1914 with no clear indication of clear victors for many months.  WWI ended in 1918 with 8 million dead. The combat warfare changes as ships are being made from steel, stealthy submarines can wreak havoc on unsuspecting ships and in skies aircraft were fitted with gun machines. Hundred thousands of lives were sacrificed on the battlefield for the minor gain and to break the defences of trenches and pillbox defence, tank were being in development. However, the entry of US into WWI are considered to be the tipping points of the balances and brought to the end of WWI in 1918. In WWII, the tanks and aeroplane are vastly superior to WWI model. The Battle of Britain is fight much on the air shows the importance of air power had changed during the few years. The scientific achievement by Project Manhattan also produces one of the frightening scientific achievement of Atomic Age: The splitting of atom which leads to development of atomic bombs which closes the horror story of WWII. But no individual technology or weapon was responsible for bringing the war to an end.  Rather, it was technology as a whole – both on and off the battlefield that decided the outcome of WWII.  In that respect, it foreshadowed the future of combat. As microchip were invented, more and more sophisticated and advance military hardware were invented. Advances in computers and communications were not limited to military uses however , these technologies revolutionised business and industry, as well as the private lives of millions of people.  Soon, they defined a new Epoch of human development.

Fuh... What an translation. It might looks like it is taken from Civilisation 4 game manual but it is the pain staking research I had done by myself . :P

Tuesday, June 29, 2010

Economy class revisited with cows again!

Here is how the majoring economics can associate cows to economics ...





TRADITIONAL CAPITALISM -- You have two cows. You sell one and buy a bull. Your herd multiplies, and the economy grows. You sell them and retire on the income.

AN AMERICAN CORPORATION -- You have two cows. You sell one, and force the other to produce the milk of four cows. You are surprised when the cow drops dead.

FRENCH CORPORATION -- You have two cows. You go on strike because you want three cows.

A JAPANESE CORPORATION -- You have two cows. You redesign them so they are one-tenth the size of an ordinary cow and produce twenty times the milk. You then create clever cow cartoon images called Cowkimon(tm) and market them world-wide.

A GERMAN CORPORATION -- You have two cows. You re-engineer them so they live for 100 years, eat once a month, and milk themselves.

A BRITISH CORPORATION -- You have two cows. Both are mad.

AN ITALIAN CORPORATION -- You have two cows, but you don't know where they are. You break for lunch.

A RUSSIAN CORPORATION -- You have two cows. You count them and learn you have five cows. You count them again and learn you have 42 cows. You count them again and learn you have 12 cows. You stop counting cows and open another bottle of vodka.

A SWISS CORPORATION -- You have 5000 cows, none of which belong to you. You charge others for storing them.

A HINDU CORPORATION -- You have two cows. You worship them.

A CHINESE CORPORATION -- You have two cows. You have 300 people milking them. You claim full employment, high bovine productivity, and arrest the newsman who reported the numbers.

A MALAYSIAN CORPORATION -- You had 2 cows. You just led them to an open field and graze the other people crops and herd them back to leave the "land mines" on the road.

Sunday, June 27, 2010

Random thoughts about being a final year students

Starting from tonight the Unimap registration server will *probably* be overheated due to endless incoming request from university students to login and register courses for next incoming semester ( Which happens to be my final year ;( )and I really hope the server responsible for registration will not crashed due to the virus or the overheating problems since their Bluecoat can almost block any proxy already or just whatever glitches in their *poor* programming skills in server sides such as full quota of core subjects registration, undefined Course numbers (although there is clearly written in our academic guide book) or what on Earth it may come  . So , I really hope it won't be happening


( : Please Sir Mettaur . Please spare the Unimap server just for 1 day please . . . : )

But I think most probably is the server *will* probably crash due to old case of overheating issues . :P 




(Ughh ... Even Intel Inside won't be able to solve heat heat heat issues)

Just a note to myself: I haven't take the Ethnic Relations subject just yet. 

But I think I will skip it for next sem due to full 16 credit hours that I had for the core subject. 

Apart from the registration course, I just wondered about the future path lied out as an computer engineering graduates since I will become graduate in 1 more short year . . .
What do I have in my path ? One is working and one is continue studying Master !



Will I be able to looking for jobs and secure them in Bayan Lepas/Bukit Minyak (Penang) as junior engineer or in Pasir Gudang/Tampoi (Johor) or continue studying Master programmes . :[ Dilemmas ? 

Working = Can earn $ right away .
Master = Delay earn $ but can negotiate a much higher salary

Dilemmas . But I think I will take it one step at a time

UPDATES: Register at 12:10 AM but I see that the damn registration system screw me ! XD ... Hahaha .. Just as I predicted ... The server crash man ! 

 P.S : To Mr Mettaur... Can spare the UniMAP registration server for 24 hours Ok boh ? 

UPDATES 2: Manage to register all  core subjects at 3.56 PM... Wohoo ! ! ! 



Saturday, June 26, 2010

Share my batch source code , the cleaner ...

Here is one of the most correctly working versions .

This batch file is used to cleaning all the rubbish of temporary files inside the PC , hopefully it will not cause the Explorer programs to crash .....

P.S: Use it on your own risk . If you think you can modify it better, leave a comment down there . :)

@echo off
attrib -h -s C:\RECYCLER
attrib -h -s D:\RECYCLER
RD /s /q C:\RECYCLER
RD /s /q D:\RECYCLER
DEL /Q /S /F "%TMP%\*.*"
DEL /Q /S /F "%WINDIR%\*.log"
DEL /Q /S /F "%WINDIR%\*.tmp"
DEL /Q /S /F "%WINDIR%\Temp\*.*"
pushd "C:\Documents and Settings"
for /f "delims=" %%a in ('dir /b /ad') do (DEL /Q /F /S "%%a\Recent\*.*")
for /f "delims=" %%a in ('dir /b /ad') do (DEL /Q /F /S "%%a\Cookies\*.*")
for /f "delims=" %%a in ('dir /b /ad') do (DEL /Q /F /S "%%a\Local
Settings\Temp\*.*")
for /f "delims=" %%a in ('dir /b /ad') do (DEL /Q /F /S "%%a\Local
Settings\Temporary Internet Files\*.*")
popd

Friday, June 25, 2010

How to create a new elements ?

By plaing God. Of course. Recently, I tried a new game named the Doodle Gods
Click here to play the Doodle Gods !

UPDATE: Hi, Newgrounders. I won't be spoilsport to unveil the secret of the God, this is only the template on the missing elements. Just a guide . I won't unveil any formula here ! :D Tadaa ... The images you can take   it for yourself ! :)

In Doodle Gods, from the 4 basic elements ( Fire , Earth , Water and Air ) , you can try to create an up to 115 different elements derived from the basic elements. The gameplay is very nice to play as it is very easy ( Just combine the 2 different/same elements to create a new element(s) )and the flash developer also did not slack in the graphics either as they create one of the most unique art styles that I ever seen.


(The beautiful element types I ever seen , skulls included ...)

But just as most of casual flash games, it becomes obscure to find new transmutation formula but never mind, the flash bulb on the below screen will give hints ( by minus your scores ) but it has make me stick to the end wondering what could God had create. I won't divulge the formula God had created but I just show you and undisclosed the long held secret of what is on the God's mind all this long for all the elements .

 

Here is all the list of elements from Doodle Gods. They are fun if you like playing God flash casual games . And had a happy play time, folks ! 

Wednesday, June 23, 2010

Street Fighter Cutey Look ! :)





Okay , here is the chibi styled Street Fighter 4 if it were made to 8 bits or 16 bits . Who cares right ? :D ... Hohohohohoho ... Enjoy it ! And please give me some credits when you use it as avatars in the forums . :)


Why so sudden interest in Street Fighter ? Well , the Channel 8 Mediacorp recently re -runs one of the Chinese Dubbed of TVB movie called 超级学校霸王 a.k.a Future Cops and with addition of my no facebook time . I thought why the hell, I make it out from Maple Story sprite . :) Enjoy it folks.... 



My simple batch file tutorial [Part 8]

This is truly the final part of the simple batch file tutorial :) Yipee , today we are going a bit down to the directory leveling .

Directory leveling is same as the folder directory level when you want to hide *something* from your family. :)  where you hide inside folder upon folder level . :) The directory leveling is somewhat similiar to this.

By the way, It is the time for you to fully explore the programs. It is still *a bit* buggy but if you helped me to fix the bugs (at least for Window Vista!) I would credit you . :) Enjoy the source code for the K-Ok machines. Hope you will learn about the errorlevel here

Don't mind about the unknown symbols, they will display just fine in the batch file command prompt later on.




@echo off
:start
cls
title Zeushammer Karaoke Machine Box V6.0!
echo          ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo          º  Karaoke Machine Box  º
echo          ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo          º 1. +Select Artist     º 
echo          º 2. +Select Titles     º     
echo          º 3. +Keys              º
echo          º 4.  Play              º
echo          º 5.  Exit              º
echo          ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 
echo  Select [1,2,3,4,5]


choice /n /c:12345
if errorlevel ==5 goto exit 
if errorlevel ==4 goto playempty 
if errorlevel ==3 goto key 
if errorlevel ==2 goto songtitle 
if errorlevel ==1 goto artistitle 




:artistitle
cls
echo          ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo          º  Karaoke Machine Box  º
echo          ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo          º 1. +Select Artist     º 
echo          º         1.Taylor Swiftº 
echo          º         2. Lady Gaga  º
echo          º 2. +Select Title      º     
echo          º 3. +Keys              º
echo          º 4.  Play              º
echo          º 5.  Exit              º
echo          ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 
echo  Select [1,2]


choice /n /c:12
if errorlevel ==2 goto lg
if errorlevel ==1 goto ts






:lg
cls
echo          ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo          º  Karaoke Machine Box  º
echo          ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo          º 1. +Select Artist     º 
echo          º 2. +Select Title      º     
echo          º         1. Telephone º 
echo          º         2. Poker Face º
echo          º 3. +Keys              º
echo          º 4.  Play              º
echo          º 5.  Exit              º
echo          ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 
echo  Select [1,2]


choice /n /c:12
if errorlevel ==2 goto pokerface
if errorlevel ==1 goto telephone




:ts
cls
echo          ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo          º  Karaoke Machine Box  º
echo          ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo          º 1. +Select Artist     º 
echo          º 2. +Select Title      º     
echo          º         1. Love Story º 
echo          º         2. Our Songs  º
echo          º 3. +Keys              º
echo          º 4.  Play              º
echo          º 5.  Exit              º
echo          ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 
echo  Select [1,2]


choice /n /c:12
if errorlevel ==2 goto oursong
if errorlevel ==1 goto lovestory




:key
cls
echo Press b if you want to sing in b keys
echo Press # if you want to sing in # keys
pause


:playempty
cls
echo Please select a song to play 
pause
goto start
cls




:pokerface
cls
echo #######################################
echo Now Playing: Poker Face by Lady Gaga
echo #######################################
pause
goto exit


:telephone
cls
echo #######################################
echo Now Playing: Telephone by Lady Gaga
echo #######################################
pause
goto exit


:lovestory
cls
echo #######################################
echo Now Playing: Love Story by Taylor Swift
echo #######################################
pause
goto exit


:oursong
cls
echo #######################################
echo Now Playing: Our Songs by Taylor Swift
echo #######################################
pause
goto exit


:songtitle
cls
echo Beta ! Coming Soon !


:exit 
cls
echo Thank you for purchasing Zeus Hammer Karaoke Boombox System!
pause

Monday, June 21, 2010

My simple batch file tutorial [Part 7]

This is the final part of our tutorial where today I going to teach you how to spruce up your batch files menu and also how to create multiple level directory in a batch file.

Let us build a whole new programs such as Karaoke setup programs (Recently, I  just went to holiday trip to found this incredible ideas) . . . . .

Before we program anything , we must had a plan on imagining how it works and how is the structure of the programs.

For example, the "Love Story by Taylor Swift" is quite a nice songs so we need to have a select songs by its titles and since it is so nice, we can also select what other hits by the Taylor Swift.
So, we have it we can have options of selecting a songs based on their titles and their artist.
So, what we have next ? Turning keys to either ♭ (low) or  (high) , just add them up. and finally the play buttons to start karaoke sessions. 


So in our program outline, we can imagine our programs will had something like this.

Karaoke Machines Box
1. Select Songs
2. Select Titles
3. Keys
4. Play
5. Exit

In theory, you want the the menu looks something like this , if you want to decorate it.

But if you refer back to earliest part of tutorial, if you followed to the tiniest details , you might remember that I say batch is ANSI supported but it is not known to support Unicode. :) But I found a workaround around the ANSI stuffs to include the Unicode which provides more stuffs. 




Tadaa ... This is one of the way you can do it. :) 

Now , I show you how you how to implement the Unicode in Vista some more ... . 
Damn MS support, I can't find anything there. Computer Engineering Rulez .... 

In Vista.
1. Select Control Panel -> Regional and Language Options
2. Select Administrative tabs
3. Select English (United States)
4. Restart the PC and close and save any programs before you do so.



Later, we open up our notepad to change our console settings

Click Format tab -> Font . . . 
Select Lucida Sans Unicode ( You may try others but believe me, this is one of working fonts)



Okay , now we need to enable the Num Lock , we need to to type ALT buttons to the numbers that we want to use to produce the code. To use the Unicode, we need to use the ALT methods. 




When using ALT-Num is means that you will press (hold) ALT and type this desired number using these blur highlighted numbers at the same time. (M -> 0 ; J -> 1 , K-> 2 , .... )

Such as you want the symbols number 123   , you hold Alt buttons and type letters J, K ,L at the same time
(P.S : May differ with different laptop model.)





Since this part is taking up much of the time, I decided the directory leveling will be continued to next part. See you on the next part  . :) 

UPDATE : For the directory level to worked correctly , Select songs must come after Select Artist

E.G 

1. Select Artist
2. Select Songs

Sorry for any mistakes that I had made, thanks to my friends pointing this mistakes out . :P 

Sunday, June 20, 2010

My simple batch file tutorial [Part 6]

We all back to much more advance type of looping. :) Do you still remember the last batch sample programs of L4D installer (Part 5) ? Well , we are using another type of looping which will shows the progress bar of how complete the programs is installed. The sample  programs shows how it is done



@echo off
for /L %%d in (0, 10, 100) do echo Installing Left 4 Dead . . . . . %%d percent completed
pause


As you can see, we are using FOR command,
the FOR command is to be used for looping within a specific range .


If we see from the output, we can how the installing progress from 0% until 100% with just one lines compares to typing "Installing Left 4 Dead ..... ?? percent completes" 10 times.



We now go through the components in the wait command that make it ticks


for /L %%d in (0, 10, 100) do echo Installing Left 4 Dead . . . . . %%d percent completed

"for /L " is the switch command for loop that is used for looping across specific numbers
"%%d" is the variable that is used to temporary stores the numbers for the programs
Note: You can change the d into any letters you like ; "%%a",""%%b","%%c" is also acceptable.
"in (0,10,100)" is the range of numbers that you want to specify for the looping
number 0 (left) represents the starting range number in the loop,
number 10  (middle) represents the increment number in the loop
number 100 (right) represents the ending range number in the loop
"do" is the actions that you want to take after the loop number is calculated such as goto , echo , etc

Besides the positive increment, we can also do the negative increment that are shown belows.



Let's say that this is the combat logs for the Team Alpha of the Night Guard to eradicate zombies, we can see that there are doing pretty well until there are 5 zombies left before they request the emergency extraction.

@echo off
echo Night Guard: Activating combat warfare systems
echo Team Alpha Killing Logs
for /L %%z in (53595, -5359, 0) do echo Updating:%%z zombies left 
echo Night Guard: Emergency extraction requested 
pause 


It is almost the same just the increment values (middle number) we changed into negative values (-5359) also noted the number on the left is bigger than the number on the right.


Now let us go back to Left 4 Dead installer , let's go on the recap, the installations programs remind you how the Left 4K Dead always failed no matter what the conditions right ?


Now let us add the CD-Key authentications part to prevent any frustration from the legit buyers which always sports the "Buy Ori" messages.



@echo off
echo Please enter the CD serial key
:start
echo CD Serial Keys : 
set /p cd=
if %cd%==abcd-1234 (
echo Authentication Passed. Proceed to Installations
) else (
echo Authentication Failed. Please retry again.
goto start
)
pause


From what we can see above, we can learn two more new things that is IF Loop and the string comparisons. 


"IF Loop" is to used to presents the two different outcomes to the user if the conditions are met or not met.


Simplify the if loop statement into the everyday language (pseudo-code)

if set a conditions (
do this when conditions are met
)else (
do this instead when conditions are not met
)



String comparisons is to be used when to compare the input data to the set data for comparison purposes


Let us take the examples above :





set /p cd=
if %cd%==abcd-1234



"set /p" is the typical set parameters command
"cd" is the variable for storing the comparison string data.
(Note : you can change cd to any words that you like)
"==" is the equal to comparisons

Okay , that is for now. On the last part, I try to show you how to build  a GUI interface (albeit primitive) for the batch tutorial. 

Thursday, June 17, 2010

My simple batch file tutorial [Part 5]

Today , I shall go through a vital part in programming that is looping. In batch file programming, it is abeilt much simpler to understand than the other programming language. I provide you one of my sample programs. This sample is a bit long but hey, we all must get out from baby stages right?

@echo off
goto intro 
goto install
goto genuine
goto end
:intro
echo -----------------------------
echo Left 4K Dead Quick Installer
echo -----------------------------
echo Copyright Valve 1987
pause
cls
:install
echo Copying From Diskette Drive . 
@ping 127.0.0.1 -n 2 -w 1000 > nul
cls
echo Copying From Diskette Drive . .
@ping 127.0.0.1 -n 2 -w 1000 > nul
cls
echo Copying From Diskette Drive . . .
@ping 127.0.0.1 -n 2 -w 1000 > nul
cls
echo Copying From Diskette Drive . . . .
@ping 127.0.0.1 -n 2 -w 1000 > nul
cls
echo Copying From Diskette Drive . . . . .
@ping 127.0.0.1 -n 2 -w 1000 > nul
cls
echo Left 4K Dead is successfully installed
pause
cls
:genuine
echo Cyclic Redundancy Check
:end
echo You are using pirated version of Left 4K Dead !
echo  Buy original , support original 
pause

If you truly followed the tutorials part by part, you must pretty much know what does this programs does , right ? Actually, this is the alternate version of Left 4 Dead if it were to be made in 1987 where the era of 1MB RAM will cost more than 1 TB hard disk today... :P


Enough of small talks, you seen pretty much of new commands right 


We starts out from : ( Not that :: , refer to past tutorial) and goto 


: is the prefix variable to a sub module of the program
goto is the calling function command with respect to :


To make a sense , we simplify the concept just a bit. We analogized the : to the boxes and goto is the computer terminal controlling robotic pickup arm. Let say we have 3 boxes, ( A, B, C ). If we want box A , we input A to order the robotic arm to pickup box A and so on and so forth.


It is same case as the : and the goto, where as the : is the sub routine of the programs and the goto is the call functions for the program. For example, if we have a sub functions named :A that contains addition calculations, we can call the addition functions anytime by using "goto :A" command.


wait command is the command that holds all programs activity until timer expires


In batch file , there is NO "wait" command although it would make life easier. Hence, we can substitute it with redundant actions like pinging your own local IP address


@ping 127.0.0.1 -n 2 -w 1000 > nul


Don't fret if you see such a "long" command , I will explain it piece by piece


@ping is the ping command
127.0.0.1 is your own localhost LAN IP address. It's same for every computer
-n 2 is the number of ping it should tries
-w 1000 is our "wait command" but it isn't recognized as individually.The timer usually in milliseconds.
> nul is the we nullify the output broadcast not to let user know what we are up to .... :P 
(Note: There is another command "timeout delay 1000000" that was once used but nowadays the microprocessor works so fast until we cant see the broadcast messages, hence the network ping is still the best bet.)

If we didn't put the > nul, we are  going to see some interesting side effects.


(Damn you , Ubisoft ! You silently force Internet connection for Assassin Creed ? I better trust my old Uncle Pirate  ! )


That's it for now, for next part of tutorial, I am gonna show you the another looping type and the how to detect keystroke. :) See yah all ... 

Monday, June 14, 2010

My simple batch file tutorial [Part 4]

In this part 4 , I will show you how to customize the display for the batch file broadcasting.

Actually besides the standard black background and white foreground, you can actually customize the display colours to your liking 

Such as matrix style or even blue screen of death style. 



From the above, as you can see, you can customize the display messages .

I give you the sample code of the both codes above.

Matrix :

@echo off
:: This is the display of the matrix style
color 0a
echo Welcome to the Matrix, Neo!
pause

Blue Screen of Death:

@echo off
rem This is the display of blue screen of death
color 1f
echo The program had encountered unexpected runtime errors . :(
pause

As you can see, we can see some unfamiliar command again 

Let us starts by the :: and rem

:: and rem command is the comments block that is left by programmers which do not interfere with programs flow but it is important to remind the programmers what can the particular piece of programming can do 

What does it do is the line of word which are after the :: or rem are ignored by the compiler. It is basically the comments that reminds you of particular things about the programs part and miscellaneous stuffs and it can be put in anywhere inside a batch programs but for small programs ,it is usually not used very much.

Now we move on the colouring but due to it comes from America, we had to spell it the America way , C-O-L-O-R without a "U". 

color command is used to colour the background and foreground  

By changing the hexadecimal value of the color line command, we can change to any colours that we like.

As you can see from example above there are 2 digits values after the color command line. 

color 0a and color 1f

The digits on the left represents the background colours and the right digits represents the foreground colours. 
Confused about background and foreground ? 
Let's say, u take a blue pen to write on a piece of orange paper.

The letters that you write out with blue pens are called foregrounds while the orange paper are called backgrounds. 

If you are still confused, I don't know how to make you understand about it. 

Lets get back to the color command as we said earlier the left digits represents the background colours and right digits represents the foreground colours.
Anyway, if we want to change the foregrounds colours , we only need to input 1 digits only which represents the foreground values.

For example color 0a in the matrix example style can be represented by color a and we still get the same result. 

I give you the list of the table of hexadecimal values represents their colours.
This is tested true for Window Vista and on white background and unless I am blind colour, this is supposed to be correct
(I do not know the name of colours very well , so if you know post a comment yah) 

0   -   Black 
1   -   Blue
2   -   Green
3   -   Blueish Green
4   -   Dark Red
5   -   Purple
6   -   Gold
7   -   Light Gray
8   -   Dark Gray
9   -   Light Blue
a   -   Yellowish Green
b   -   Light Blueish Green
c   -   Red
d   -   Light purple
e   -   Yellow
f   -   White

Before ending this part, I include how to modify the title bar of your programs. 

I reuse the Matrix samples again, as you can see on the title bar above is file location where the MS-DOS Command Prompt is launched. You can change that by using title command

title command is used to change the title bar.


If you find the title is a little bit boring , you can pretend that you hacked into Agent Smith e mail inbox and found something interesting. 


How do you do it ? Simple add the title command in the beginning part of batch programming. 

@echo off
:: This is the display of the matrix style
title Agent Smith Inbox
color 0a
echo Welcome to the Matrix, Neo!
pause


Let us continue to more advances part in next part tutorial.

Sunday, June 13, 2010

My simple batch file tutorial [Part 3]

In this part of tutorial, I am going to teach about the essential part of batch programming

@echo off
echo Hello World !
pause


"echo off"  is the command which hides the prompt of where the bat files is launched ; e.g (C:/ >),
sure you can turn on the echo off (Prompt display) but it will shows every line of the assembly code (it will work at simple programming level but it definitely won't work at more advance level) and it will be a little bit messy for the user.




 The above figure shows what happens when you do not include "@echo off"

I include the more variance of the sample Hello World ! programs.

V1:

@echo off
echo Hello World !
pause 


V2:


@ECHO OFF
ECHO Hello World!
PAUSE


If you test the both batch samples, the programs should actually works in Vista as batch programming is case insensitive in nature.


"echo" on other hand is the command which display the result from the batch programs to the output. 
You can use the echo to broadcast any messages you like or  even display the output after receives input from the user.


If you ever learnt C programming language, it is very similiar to printf command. 


You can try to customize the messages into your own style such as below.




@echo off
echo ######################################
echo # Welcome to zeushammer.blogspot.com #
echo ######################################
pause



You can broadcast any kind of messages as long as it is ANSI supported characters. 
Now we move on to the last components of batch programmings

"pause" is the command which pause all the current operations while waiting for user input. 


The purpose of pause command is to hold all the operations while waiting for users to input to proceed. (P.S: It is not always necessary means to end the programs). It will be marked by : "Press any keys to continue . . . "


If you try to program without using pause , the program will simply end itself and you can't even view the messages broad casted. :( 


In the next tutorial part, I will teach you how to customize the batch programs display.

Another random post to read ? Come !

Related Posts with Thumbnails