GLBasic forum

Main forum => GLBasic - en => Topic started by: bigsofty on 2008-Feb-11

Title: Remark Blocks
Post by: bigsofty on 2008-Feb-11
Can we change the way that remaking a block applies its remark can be very frustrating sometimes...

Code (glbasic) Select
GETSCREENSIZE screenwidth,screenheight
sx=screenwidth*.2;sy=screenheight*.5   //start point
//ex=screenwidth*.8;ey=screenheight*.5   //end point
bx=screenwidth*.5;by=screenheight*.5   //curve towards point
//animTime=5000   //animation time of 2 seconds
Block remarked, becomes...

Code (glbasic) Select
//GETSCREENSIZE screenwidth,screenheight
//sx=screenwidth*.2;sy=screenheight*.5   //start point
ex=screenwidth*.8;ey=screenheight*.5   //end point
//bx=screenwidth*.5;by=screenheight*.5   //curve towards point
animTime=5000   //animation time of 2 seconds
What I wanted was...

Code (glbasic) Select
//GETSCREENSIZE screenwidth,screenheight
////sx=screenwidth*.2;sy=screenheight*.5   //start point
//ex=screenwidth*.8;ey=screenheight*.5   //end point
////bx=screenwidth*.5;by=screenheight*.5   //curve towards point
//animTime=5000   //animation time of 2 seconds
and if I reapply block remark...

Code (glbasic) Select
GETSCREENSIZE screenwidth,screenheight
sx=screenwidth*.2;sy=screenheight*.5   //start point
//ex=screenwidth*.8;ey=screenheight*.5   //end point
bx=screenwidth*.5;by=screenheight*.5   //curve towards point
//animTime=5000   //animation time of 2 seconds
Now this allows for large blocks of code to be remarked out, without having to worry if the code has already gotten remarks, 'unremarked' and then causing compilation errors...

How is this done?

This is how it could be applied in pseudo code...

IF first_two_block_chars$ = '//' THEN
BEGIN
   REPEAT
     READBLOCKLINE(Current_line$)
     IF First_Two_Chars_Of_Current_Line$ = '//' THEN
        DELETE First_Two_Chars_Of_Current_Line$
     WRITEBLOCKLINE(Current_line$)
   UNTIL End_Of_Block
END
ELSE
BEGIN
   REPEAT
     READBLOCKLINE(Current_line$)
        Current_line$ =  '//' + Current_Line$
     WRITEBLOCKLINE(Current_line$)
   UNTIL End_Of_Block
END

This is how most languages apply block code remarking. It allows large blocks of code to be remarked in and out without having to worry if the block already contains remarks.
Title: Remark Blocks
Post by: Moru on 2008-Feb-11
Temporary solution: I usually put an IF block around larger codeblocks so I don't have to worry about it.

Code (glbasic) Select
IF 1 = 0
     Code you want commented out
ENDIF
Title: Remark Blocks
Post by: Kitty Hello on 2008-Feb-11
That's what I do, too :D
Anyway - It's a "unexpected feature". I'll fix it.
Title: Remark Blocks
Post by: bigsofty on 2008-Feb-11
Quote from: MoruTemporary solution: I usually put an IF block around larger codeblocks so I don't have to worry about it.

Code (glbasic) Select
IF 1 = 0
     Code you want commented out
ENDIF
No use for complete Functions I'm afraid. Funny enough commenting out large blocks of code has become a integral part of my debugging... a bit like a doctor removing body parts till he finds the infected limb! :P
Title: Remark Blocks
Post by: Kitty Hello on 2008-Feb-11
Quote from: bigsoftya bit like a doctor removing body parts till he finds the infected limb! :P
...I'd start with the brain.
Title: Remark Blocks
Post by: Moru on 2008-Feb-11
For commenting out whole functions you just rename them and create a new dummy one or put the if statemen inside the whole function :-)
Title: Remark Blocks
Post by: PeeJay on 2008-Feb-11
or just comment out the call to the function .....
Title: Remark Blocks
Post by: bigsofty on 2008-Feb-11
Quote from: GernotFrisch
Quote from: bigsoftya bit like a doctor removing body parts till he finds the infected limb! :P
...I'd start with the brain.
What brain? :D