HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

programming basics. real basic.

07-22-2003, 09:52 PM#1
gurubvin
this is something i wrote to someone asking help for how to get started on jass. if this'll help u, use it.

b4 i start here's some definitions.

1) function- the best explanation of this i can give is that it's a small program for a specific task. a program, such as wc3, is made up of functions.

2) script- this is similar to a programming language. the difference is that a script is made to work within a certain programming language. scripts are usually simpler, but having less capabilities.

3) code- using script you create a function. code refers to the written statements you have made to create that function. like if u write a story, u use a language. i.e. english, or spanish, or swedish, etc. the actual words written in the book is the "code"

4) comments- these are interjections u put into ur code to remind u of what ur telling the computer to do in case it becomes vague to u. this is signified by "//". if u see these b4 any statement it means the computer ignores it and it's just there for ur benefit. this is how i'll walk u through this function i wrote as well. each comment refers to the line below it.

5) variable- a value u can change. u'll need to actually experiment with this to figure it out, but basically it's space in memory that the computer sets aside for u to save data. it can't just be ne data however. it must be the same as what the space was made for. so for example u couldn't save the letter "a" in a variable made for a number.

// for example, this refers to the line starting at "function Write
//takes.... this is the function heading. it'll give u the name of
//the function, which is Write. don't stress bout the takes and
// returns right now.

function Write takes nothing returns nothing

//scroll down past the comments to see the code first.
//the term local means ur creating a variable. string is the
//variable type. a string is anything written. it's not a value u
//can arithmetically alter. as an example, think of a picture
//if u had a picture of an apple, u couldn't eat it, or smell it.
// but u can look at it and say, that's an apple. u can take it
//into photo shop, and make it look like an orange, but
//never will u be able to eat it. it's just an image. that's how a
//string works. statement is the string name. anytime u need
//to access this particular string u use the name statement.
//"hello" is the value given to it. if ever u tell the pc to display
//the variable statement, it'll say "hello"

local string statement = "hello"

//This is a function call. what ur doing here is calling
//a function. The function is named DisplayTextToForce. Ignore,
//Player(0). statement tells the comp to display statement,
//which would display ______ on the screen (fill in the blank)

call DisplayTextToForce(Player(0), statement)

//This says the function is done.
endfunction

that's it. study this and do the convert to custom text in ur WE to get a better idea of how this works. Look at that and try to find the different parts of the function. if u need nething else post on the forum. but b4 doing that experiment first so that ur question is specific and a not a vague, help me. it'll be much easier to answer the problems ur having that way, and prolly make it easier for us to help each other out. if i'm wrong somwhere here and if the mods want, just edit my post, or post something new.