PtokaX forum

Development Section => HOW-TO's => Topic started by: pHaTTy on 25 December, 2003, 20:37:06

Title: HOW-TO: Use basic if's and ends
Post by: pHaTTy on 25 December, 2003, 20:37:06
ok while i here a quick little thread to remind you if the tabbing system

for if end

for for end

== is if it eqals

= is it make it equal


ok tabs

ok here is one of a projects main function ive been working on, i have removed lotsa stuff so you see only an example this will not work for you


function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end
end
end



now for tabbing look how messy it looks, first tab all the lines that the function looks over

function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end

now there is a for, every for must come to an end


function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end -- if
end -- for
end -- function

now to tab them up more


function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end -- if
end -- for
end -- function


now for some ppl this will be confusing at first so re read it sorry i sometimes dont make sense to myself lol but theres a little reminder, that how i used to remind myself lol

l8rr,,
Title:
Post by: NightLitch on 25 December, 2003, 21:57:11
One easy way to is:

To each function there is always an end.
And to every if there is always an end.
And to every for there is always an end.

and if you use:


if
elseif
elseif

it will be just one

end

what do you guys call this "table" call for ?? my english sucks
right now...

accociative or ???
Title:
Post by: plop on 25 December, 2003, 22:33:18
associative (or something like that, terible word 2 spell).

plop
Title:
Post by: pHaTTy on 25 December, 2003, 22:34:47
if you associate something with something i guess yes its

associate lol :)

Damn PLOP NOOOOOOOOOO!!!! :P

that screen i used to see it every 2 minutes on win98 lol
Title:
Post by: plop on 25 December, 2003, 22:44:37
the key is associated with a vallue, thats why some wise ass named it an associative array.
maby a linked array would have been easyer, definatly 2 spell.

good that you like my avatar phatty.

plop
Title:
Post by: kepp on 26 December, 2003, 23:42:45
I never understood why either, but with a little google search i found out that it's purposes is, to keep up the structure of the code.
and yes, i aslo notice that it became very easy to read it that way aswell..

:D