Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why underscore for identifier ?

Status
Not open for further replies.

juggyjuggy

Programmer
Mar 24, 2002
7
BE
I know this is a very stupid question, but i'm looking through some code i downloaded and see a lot of variables declared preceding with an underscore ...
Thx for answering,
JuGgY ...

eg :

// Draw background
_x1 := BACK1X;
_x2 := BACK2X;
_p.y := 0;
for _z := 0 to 11 do
begin
_p.x := _x1;
D3DXDrawSpr(BACK1, NIL, @_p, NIL, NIL, 0, $FFFFFF, BACKAL);
_p.x := _x2;
D3DXDrawSpr(BACK2, NIL, @_p, NIL, NIL, 0, $FFFFFF, 255 - BACKAL);
inc(_x1, 128);
dec(_x2, 128);
if _z = 3 then begin _x1 := BACK1X; _x2 := BACK2X; _p.y := 128; end;
if _z = 7 then begin _x1 := BACK1X; _x2 := BACK2X; _p.y := 256; end;
end;
 
I don't know. Coding standards at my job require us to put the variable's scope and type in the name, followed by the dreaded underscore: LSTR_Text for a local string or AINT_Number for an integer passed in as an argument.
 
I have seem worse coding where in a huge function the variables used where x1 thru x15 and z1 thru z10. On top of that, they were all declared as variants so they each could start out as one thing and end up something else entirely. It was a nightmare to recode the function using more descriptive variables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top