Home AMX User Forum NetLinx Studio

The misery of a misplaced ;

After what seemd like hours, re-compiling w/ debug strings every where I could think, changing stack vars to local to watch in debug, completely re-writing several section, starring at the same sections of code over and over again with out anything obvious starring back and then I finally found it. Of course this being the 1st code I've written since upgrading to NS3 yesterday and now dealing with the crashing to add to my insanity one simple little semi colon in the wrong place. How it got there? Probably a quick copy and paste. Now so obvious although before invisible. I got the 1st debug string but nothing after and never returned to the code that called this function.
DEFINE_FUNCTION fnComcastParseChannels(CHAR iBuff[],INTEGER iParseStrIndx ) 

     {
     LOCAL_VAR CHAR cCH_Buff[8000] ;
     STACK_VAR INTEGER nFBS ;
     LOCAL_VAR INTEGER nCurChannel ;
     
     cCH_Buff = iBuff ;
     
     fnComcast_Debug("'Parsing Ch. for Section # ',itoa(iParseStrIndx),'.  line-<',ITOA(__LINE__),'>',crlf") ;
     WHILE(find_string(cCH_Buff,'20%;">',1)) ; 
	  {
	  fnComcast_Debug("'Parsing Ch. inside while.  line-<',ITOA(__LINE__),'>',crlf") ;
	  REMOVE_STRING(cCH_Buff,'20%;">',1)
	  nFBS = find_string(cCH_Buff,'</',1)
	  nCurChannel = ATOI("GET_BUFFER_STRING(cCH_Buff,nFBS-1)") ;
	  fnComcast_Debug("'Parsing Channels # ',itoa(nCurChannel),'. line-<',ITOA(__LINE__),'>',crlf") ;
	  if(find_string(cCH_Buff,'C0;">',1))
	       {
	       REMOVE_STRING(cCH_Buff,'C0;">',1)
	       nFBS = find_string(cCH_Buff,'</',1)
	       sComcast[nCurChannel].CH_Name = GET_BUFFER_STRING(iBuff,nFBS-1) ;
	       sComcast[nCurChannel].CH_Number = nCurChannel ;
	       sComcast[nCurChannel].CH_Type = CH_SECTION_NAMES[iParseStrIndx] ;
	       }
	  else
	       {
	       sComcast[nCurChannel].CH_Name = 'n/a' ;
	       sComcast[nCurChannel].CH_Number = MAX_NUM_CH + 1 ;
	       sComcast[nCurChannel].CH_Type = 'err' ;
	       }
	  }
     fnComcast_Debug("'Parsing Channels ends.  line-<',ITOA(__LINE__),'>',crlf") ;
     cCH_Buff = '' ;
     
     RETURN ;
     }

Now to try & undo all the stupid crap I did for no reason, oy vey!

Comments

  • jjamesjjames Posts: 2,908
    Ouch . . . that's a buzz killer.

    I'm surprised it let you compile with where it was. If you were to do that with an IF, SWITCH or SELECT - it chokes . . . bug in the compiler perhaps?
  • ericmedleyericmedley Posts: 4,177
    jjames wrote: »
    Ouch . . . that's a buzz killer.

    I'm surprised it let you compile with where it was. If you were to do that with an IF, SWITCH or SELECT - it chokes . . . bug in the compiler perhaps?

    I think there might be something going on. In another post I mentioned a weird anomoly involving define_Module.


    I've been working on a new system lately and was putting in two modules.

    Module for Mitsubishi TV
    Module for Marantz receiver.

    The marantz module quit working altogether unexpectedly. Online event would never fire on the serial device in the module. Variables would show up in the debugger wiht zero values. You could change them but nothing worked. I trashed all the .tkos and .tkns, compiled individual files one at a time, etc...

    The project continued to comple and/or build with zero errors.

    After beating and banging for several hours, on a whim I tried reversing the order of the module declarations in code just to see if the compile was missing something.
    so I reversed

    Module for Mitsubishi TV
    Module for Marantz receiver.

    for

    Module for Marantz receiver.
    Module for Mitsubishi TV

    complied, uploaded and it worked just fine. Crisis averted, you can all go home now.

    So, then to see if there was something to do with the order in which they occured I put them back to

    Module for Mitsubishi TV
    Module for Marantz receiver.

    compiled, uploaded and it works still to this day.

    So, there seems to be something that's getting past somehow. I'm not too surprised that vining's error compiled. I can still remember the old days of Axcess where you could get away with murder all the time. Ah, those halcyon days... :D
  • It compiles with no errors in NS2 also, so this particular issue isn't an NS3 thing. Semi-colons in Netlinx can cause all kinds of unexpected results. As a matter of fact here's one where JJames showed a compiler bug related to semi-colons: http://www.amxforums.com/showthread.php?t=4938. There are only certain times when they're required so I don't bother with the semicolons normally. The times I've run into instances where they're needed, I think the compiler threw an error if I didn't use them which made it easier to debug.

    Bummer about all the time wasted Dan.

    --John
  • viningvining Posts: 4,368
    John Gonzales wrote:
    so this particular issue isn't an NS3 thing.
    I didn't think it was an NS3 related issue, it was just the fact that being new to NS3 w/ it crashing ever other uploaded compounded my misery & frustration.

    I always use semi-colons and have learned where they can & can't go but somehow that sucker was invisible and laughing at me for hours. I've done dumber stuff but the amount of re-writing I went through to end up with a simple, stupid misplaced semi-colon made me want to kick myself in the a$$.
  • jjamesjjames Posts: 2,908
    vining wrote: »
    I always use semi-colons and have learned where they can & can't go but somehow that sucker was invisible and laughing at me for hours. I've done dumber stuff but the amount of re-writing I went through to end up with a simple, stupid misplaced semi-colon made me want to kick myself in the a$$.

    Ctrl-Z . . . . :D
  • The NS3 thing was a comment related more to Eric's comment. I know how you feel with all that code re-writing. What I hate too is when you do the rewrites and in the end it works but you end up thinking "I think one of those earlier ones was better...."

    That might be a good feature addition for Studio. F7 compiles and backs up 10 iterations back in case you need to restore to your previous code.

    Ahhh the life of programming :)

    --John
  • a_riot42a_riot42 Posts: 1,624
    Why use semi-colons?
    Paul
  • viningvining Posts: 4,368
    a_riot42 wrote:
    Why use semi-colons?
    Mostly just a habit. Other languages require them and it just indicates the end of a line or statement. I don't know if it make the compilers life any easier but it might. Mostly, coders that I have a lot of respect for use them so when I started with Netlinx I followed suit.

    FYI, personally I do a lot of stuff that isn't required that works with my anal OCD ADD quirks and in my head they make things, for me, more readable & organized. I actually can't stand the way most of you guys on the forum write code but maybe cuz you guys are programmers and I still don't consider myself one, that's why. Well, I do but I don't. I know the way I write & structure code has got to make you guys sick but I am what I am and I do what I do.
  • a_riot42a_riot42 Posts: 1,624
    vining wrote: »
    a_riot42 wrote:
    Other languages require them and it just indicates the end of a line or statement.

    I use them in the languages that require them of course. Never saw a need to use them in Netlinx though. I would suggest not using them if they will create hard to find bugs, but I know old habits die hard.
    Paul
  • viningvining Posts: 4,368
    a_riot42 wrote:
    I would suggest not using them if they will create hard to find bugs,
    Obviously you don't suffer from being anal w/ OCD & ADD cuz if you did you'd realize what you're asking. Besides I can't blame the semicolon for my stupidity, it was just one of those things, one of those days.
  • ericmedleyericmedley Posts: 4,177
    vining wrote: »
    a_riot42 wrote:

    Obviously you don't suffer from being anal w/ OCD & ADD cuz if you did you'd realize what you're asking. Besides I can't blame the semicolon for my stupidity, it was just one of those things, one of those days.

    so would the proper saying then be:

    "It is the poor programmer who blames his punctuations?"

    I blame my computer for almost everything that goes wrong.

    :D:D:D
  • Spire_JeffSpire_Jeff Posts: 1,917
    You might want to take a look at setting up a SVN (http://tortoisesvn.net). I use tortoiseSVN and the file compare utility can be a life saver. If I make some changes on a new job and things are working like they should, I just compare the current file with the previous version to easily see what I changed. You can also compare between two projects easily. If you have a job in which there is a routine that you changed/upgraded/fixed on another job, it is very easy to compare the two files and copy over the necessary code.

    Jeff
  • viningvining Posts: 4,368
    Spire_Jeff wrote:
    You might want to take a look at setting up a SVN (http://tortoisesvn.net).
    I already use NotePad++ universal editor w/ a file compare feature (sourceforge) and it appears that NS3 now has a file compare feature too but I didn't have a previous copy of this particular code. I think when I decided to add the "while" I just copied the find_string from elsewhere. I pretty much wrote all the code and expected the module to just work, which for the most part it did until it got to the semicolon.
  • We have seen this as well.
    I had a situation the other day where I needed a semi-colon at the end of declaring stac vars inside timeline events.
    Without the semi-colon, the compiler would error out.

    regards
    Craig
  • a_riot42a_riot42 Posts: 1,624
    cmatkin wrote: »
    We have seen this as well.
    I had a situation the other day where I needed a semi-colon at the end of declaring stac vars inside timeline events.
    Without the semi-colon, the compiler would error out.

    regards
    Craig

    I would be interested in seeing that. Can you post the relevant code?
    Paul
  • Joe HebertJoe Hebert Posts: 2,159
    a_riot42 wrote: »
    I would be interested in seeing that. Can you post the relevant code?
    This is an oldie but a goodie. You don't have to use a semi-colon but it does fix the problem..

    http://amxforums.com/showpost.php?p=3587&postcount=5
Sign In or Register to comment.