|
|
View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
'Match Brace' going screwy.... |
Posted: Tue Apr 21, 2020 2:30 am |
|
|
Having an odd problem. Handling a large block of code and trying to
keep track of braces opening and closing.
Finding that the 'match brace' function in the IDE seems to have got
completely confused:
Code: |
switch (todo) { //attempt to match this brace
case KEYBOARD:
//draw a text keyboard with entry window - drops through to handler
input_mode=HANDLE_BOARD; //flag to main code for keyboard input
message[0]='\0'; //clear the input message
tick=50;
shift=FALSE; //start with shift off
//now drop through to handler so this can be called to display and handle
case HANDLE_BOARD:
API_LIST();
API_CLEAR(1,1,1);
Rv=make8(graphconfig.backcolour,2);
Gv=make8(graphconfig.backcolour,1);
Bv=make8(graphconfig.backcolour,0);
API_CLEAR_COLOR_RGB(Rv,Gv,Bv);
API_COLOR_V(graphconfig.textcolour);
colour = graphconfig.textcolour; //set colour
API_CMD_FGCOLOR(graphconfig.buttoncolour);
API_TAG_MASK(TRUE);
if (shift)
{
API_CMD_KEYS(15, 130, 590, 50, (int16_t)GraphConfig.buttonfont, 0, "!\"£$%^&*()-+");
API_CMD_KEYS(45, 190, 604, 50, GraphConfig.buttonfont, 0, "qwertyuiop{}");
API_CMD_KEYS(65, 250, 604, 50, GraphConfig.buttonfont, 0, "asdfghjkl:@~");
API_CMD_KEYS(85, 310, 540, 50, GraphConfig.buttonfont, 0, "|zxcvbnm<>?");
API_TAG(13); //enter tag
API_CMD_BUTTON(675,130, 110, 140, GraphConfig.buttonfont, 0, "Return");
API_TAG(' '); //enter tag
API_CMD_BUTTON(135, 370, 370, 50, GraphConfig.buttonfont, 0, " ");
API_TAG(8);
API_CMD_BUTTON(609, 130, 50, 50, GraphConfig.buttonfont, 0, "<-");
API_TAG(14); //Using SO as shift
API_CMD_BUTTON(15, 370, 50, 50, GraphConfig.buttonfont, 0, "v");
} //It says this is the matching brace!....
else
{
API_CMD_KEYS(15, 130, 590, 50, GraphConfig.buttonfont, 0, "1234567890_=");
API_CMD_KEYS(45, 190, 604, 50, GraphConfig.buttonfont, 0, "QWERTYUIOP[]");
API_CMD_KEYS(65, 250, 604, 50, GraphConfig.buttonfont, 0, "ASDFGHJKL;'#");
API_CMD_KEYS(85, 310, 540, 50, GraphConfig.buttonfont, 0, "\ZXCVBNM,./");
API_TAG(13); //enter tag
API_CMD_BUTTON(675,130, 110, 140, GraphConfig.buttonfont, 0, "Return");
API_TAG(' '); //enter tag
API_CMD_BUTTON(135, 370, 370, 50, GraphConfig.buttonfont, 0, " ");
API_TAG(8);
API_CMD_BUTTON(609, 130, 50, 50, GraphConfig.buttonfont, 0, "<-");
API_TAG(14); //Using SO as shift
API_CMD_BUTTON(15, 370, 50, 50, GraphConfig.buttonfont, 0, "^");
}
API_TAG_MASK(FALSE);
API_COLOR_V(RED);
API_CMD_TEXT(30, 40, 29, 0, prompttxt);
API_COLOR_V(graphconfig.textcolour);
//Now need to draw the message box and show the current message
API_CMD_TEXT(400, 40, 29, 0, message);
API_DISPLAY(); // Instruct the graphics processor to show the list
API_LIB_EndCoProList(); // Finish the co-processor list burst write
API_CMD_SWAP();
API_LIB_AwaitCoProEmpty(); //and execute
break;
|
If I highlight the opening brace after the switch statement, and select
'match brace', it selects the closing brace from the (shift) section.
The code actually compiles OK, so there is no brace mismatch.
I can't see any reason at all for the brace match to get confused, except
possibly the use of {} in the text for the buttons.
I am doing a 'drop through' on a switch case, but this is legitimate.
Has anyone seen this type of behaviour before?.
Any idea of what causes it?.
Going mad!... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Apr 21, 2020 3:06 am |
|
|
Yes, it's this:
"qwertyuiop{}"
That is causing the issue. It's 'weird', it is seeing the second brace here
but not the first. Though they should be ignored, being inside the
inverted commas. So it loses count of the open/closed braces.....
If I 'remark' this line out, the match starts working OK. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Apr 21, 2020 12:36 pm |
|
|
weird... yup.
I was thinking maybe a 'hidden' extra { brace but..... it compiles fine, so the compiler is happy, just the 'matching braces counter' section of the IDE is upset. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Apr 21, 2020 12:44 pm |
|
|
Yes, it is successfully ignoring braces that are remmed out, but not in inverted commas. Will point this one out and hopefully it'll be fixed in a while.
What do you think of the 'best of' section. Suggestions please from everybody
on what to include... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Apr 21, 2020 1:50 pm |
|
|
it is a GREAT idea, hopefully little personal 'gems' will be added quickly.
I'm stuck trying to decide HOW to move, 3, 3200# ( 1500KG) logs from a steep hill and not a) kill myself or b) destroy the 100 year old septic tank. Kinda preoccupied with that, being it's tomorrows job.....
I do like the Olympic Averaging for analog sensor readings to get rid of 'weird' numbers..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Apr 22, 2020 12:43 am |
|
|
Be very careful...
Moving heavy things is worthy of making very sure that no part of
yourself is 'in the way'. Real care.
Levers, rollers, keeping hands and feet out of the way.
So repeat 'be careful'.
Hope you manage this without any problems.
New entry created for 'ADC filtering', with links to Olympic, and median
filters, and simple examples of basic averaging, and a rolling average. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Apr 23, 2020 11:32 am |
|
|
Hay Mr. T.
Well I still got all 10 fingers and toes ! Only took 4 hours. BIG problem is dealing with 'tame' fox that tried to make breakfast from my cat ! He almost bit my toe !
Too upset to concentrate to 'play with PICs'.....
My priorities have changed this 8:04 AM today.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Apr 23, 2020 12:17 pm |
|
|
I saw your post about nearly being bitten. Must admit 'wondered'... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Apr 23, 2020 1:11 pm |
|
|
I'm in a semirural area and city don't care about gal feeding fox and racoons. fox has killed dozens of laying hens, nearly got my cat. they may be 'cute' but really they shouldn't get that close to humans....
on the plus side it's 61.7000*F in the greenhouse, oops now 61.4750*F, sigh. maybe having a PIC report every second is 'too much information' ?
I'm thinking I should average the averages over a minute. I used to just take 4 readings per minute in the good old' 16C84 days... |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
Re: 'Match Brace' going screwy.... |
Posted: Thu Apr 30, 2020 9:32 am |
|
|
Ttelmah wrote: | Having an odd problem. Handling a large block of code and trying to
keep track of braces opening and closing.
Finding that the 'match brace' function in the IDE seems to have got
completely confused:
Code: |
switch (todo) { //attempt to match this brace
case KEYBOARD:
//draw a text keyboard with entry window - drops through to handler
input_mode=HANDLE_BOARD; //flag to main code for keyboard input
message[0]='\0'; //clear the input message
tick=50;
shift=FALSE; //start with shift off
//now drop through to handler so this can be called to display and handle
case HANDLE_BOARD:
API_LIST();
API_CLEAR(1,1,1);
Rv=make8(graphconfig.backcolour,2);
Gv=make8(graphconfig.backcolour,1);
Bv=make8(graphconfig.backcolour,0);
API_CLEAR_COLOR_RGB(Rv,Gv,Bv);
API_COLOR_V(graphconfig.textcolour);
colour = graphconfig.textcolour; //set colour
API_CMD_FGCOLOR(graphconfig.buttoncolour);
API_TAG_MASK(TRUE);
if (shift)
{
API_CMD_KEYS(15, 130, 590, 50, (int16_t)GraphConfig.buttonfont, 0, "!\"£$%^&*()-+");
API_CMD_KEYS(45, 190, 604, 50, GraphConfig.buttonfont, 0, "qwertyuiop{}");
API_CMD_KEYS(65, 250, 604, 50, GraphConfig.buttonfont, 0, "asdfghjkl:@~");
API_CMD_KEYS(85, 310, 540, 50, GraphConfig.buttonfont, 0, "|zxcvbnm<>?");
API_TAG(13); //enter tag
API_CMD_BUTTON(675,130, 110, 140, GraphConfig.buttonfont, 0, "Return");
API_TAG(' '); //enter tag
API_CMD_BUTTON(135, 370, 370, 50, GraphConfig.buttonfont, 0, " ");
API_TAG(8);
API_CMD_BUTTON(609, 130, 50, 50, GraphConfig.buttonfont, 0, "<-");
API_TAG(14); //Using SO as shift
API_CMD_BUTTON(15, 370, 50, 50, GraphConfig.buttonfont, 0, "v");
} //It says this is the matching brace!....
else
{
API_CMD_KEYS(15, 130, 590, 50, GraphConfig.buttonfont, 0, "1234567890_=");
API_CMD_KEYS(45, 190, 604, 50, GraphConfig.buttonfont, 0, "QWERTYUIOP[]");
API_CMD_KEYS(65, 250, 604, 50, GraphConfig.buttonfont, 0, "ASDFGHJKL;'#");
API_CMD_KEYS(85, 310, 540, 50, GraphConfig.buttonfont, 0, "\ZXCVBNM,./");
API_TAG(13); //enter tag
API_CMD_BUTTON(675,130, 110, 140, GraphConfig.buttonfont, 0, "Return");
API_TAG(' '); //enter tag
API_CMD_BUTTON(135, 370, 370, 50, GraphConfig.buttonfont, 0, " ");
API_TAG(8);
API_CMD_BUTTON(609, 130, 50, 50, GraphConfig.buttonfont, 0, "<-");
API_TAG(14); //Using SO as shift
API_CMD_BUTTON(15, 370, 50, 50, GraphConfig.buttonfont, 0, "^");
}
API_TAG_MASK(FALSE);
API_COLOR_V(RED);
API_CMD_TEXT(30, 40, 29, 0, prompttxt);
API_COLOR_V(graphconfig.textcolour);
//Now need to draw the message box and show the current message
API_CMD_TEXT(400, 40, 29, 0, message);
API_DISPLAY(); // Instruct the graphics processor to show the list
API_LIB_EndCoProList(); // Finish the co-processor list burst write
API_CMD_SWAP();
API_LIB_AwaitCoProEmpty(); //and execute
break;
|
If I highlight the opening brace after the switch statement, and select
'match brace', it selects the closing brace from the (shift) section.
The code actually compiles OK, so there is no brace mismatch.
I can't see any reason at all for the brace match to get confused, except
possibly the use of {} in the text for the buttons.
I am doing a 'drop through' on a switch case, but this is legitimate.
Has anyone seen this type of behaviour before?.
Any idea of what causes it?.
Going mad!... |
Here is a tip I've used for many years...
Code: |
SomeCode()
{
int das;
das=0;
das+=2;
} // end SomeCode()
|
Seems silly when the lines of code are all on one page, but when the braces span 2 or 3 pages of code it's easier to search for "end SomeCode" to find the match.
For really screwy situations:
Open the file in Visual Studio it has the best brace matching, VS2017 is the best.. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Apr 30, 2020 12:26 pm |
|
|
The marker is just as dependant on you keeping it in balance as the
braces. If you are deleting a lot of code, it is equally easy to end up
with a start and no tail marker or a tail and no start.
This code has over 70 cases. A section was deleted and I needed
to check that I had kept the braces balanced. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|