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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for problem 1

Status
Not open for further replies.

reggler

Programmer
Nov 13, 2008
63
CA
Hi There,

I'm experiencing something weird and i'm not able to resolve it - i don't know if it's again one of these tcl/tk parser issues that you just need to know or if i'm totally off but look at my code:
All we're really interested in is the $passone condition.
Code:
	    #first we check for Pass: 1 to see if that has passed or failed
	    set passone [string first "Pass: 1" $serial::rxBuffer]
	    #if we found PassOne in the console
	    if {$passone != -1} {
		    .serialMon.cons insert end "Found 'Pass: 1'" system
		    #We will loop until we get a status to analyze
		    set statcond 1
		    set timeout 0
		    while {$statcond && ($timeout < 600)} {
				set statfail [string first "Status: Failed" $serial::rxBuffer]
				set statpass [string first "Status: Passed" $serial::rxBuffer]
				if {$statfail != -1} {
					.serialMon.cons insert end "Found 'Status: pass or fail'\n" system
					.serialMon.cons insert end "Error in first test. Check loopbacks! Aborting test...\n" error
					for { set i 1 } { $i <= 10 } { incr i }  {
						finaltest::delay $i						
					}
					Execute_Command $serial::hndl_com_port "reset"					
					set choice [tk_messageBox -type ok -default ok -message "First test failed!\nSecure loopback connectors and restart test." -icon warning]
					return 1
				}
				if {$statpass!=-1}  {
					.serialMon.cons insert end "Successfully passed first test!" system
					set statcond  0
				}
				finaltest::delay 100
				set timeout [expr $timeout + 1]
		    }
		    if {$timeout >= 600} {
			    .serialMon.cons insert end "Timeout appeared, unable to test first result!" error
			    set choice [tk_messageBox -type ok -default ok -message "Timeout appeared, unable to test first result!\nRestart test." -icon warning]
		    }
	    }
Alright, now this seems to work as expected as long as the little for loop is commented out:
Code:
				#	for { set i 1 } { $i <= 10 } { incr i }  {
				#		finaltest::delay $i						
				#	}
as soon as i put this for loop in the whole algorithm, the
Code:
set passone [string first "Pass: 1" $serial::rxBuffer]
doesn't seem to work anymore in other words i don't see
Found 'Pass: 1'
appear in .serialMon.cons even tho I clearly see "Pass: 1" showing up properly.
I would not see how the for loop is giving feedback to the string first command
 
Hold on, I think i got this one....nevermind i got it. The problem is ahead of the code and in certain conditions, rxBuffer gets purged a little too late which removes the "Pass: 1" from it...
 
Hi Reggler,

Why have you choosed to bother with Tcl/Tk?
IMHO there are better languages you can build Tk GUIs with, e.g.: Perl and Python.
Tcl is interesting language, but not so wide used as Perl or Python.
It is strongly interpreted line by line, therefore the parser has some issues/limitations:

One example: if you write
Code:
if { condition } {
  # do something
} else {
  # do something else
}
it's OK

But if I use my Perl- or C-style and write
Code:
if { condition } {
  # do something
} 
else {
  # do something else
}
I get an ERROR!
In the second case the parser cannot recognize, that IF continues with ELSE.

If you want to write in Tcl/Tk you need to know about such problems.
 
hehe yup, I've ran into this issue too and i was like " HUH???? wtf???" haha but you know, i'm in the process of taking over an existing software project and we're developing a new system as well using perl.... I'm looking forward to working on that :)
Anyways, TCL is interesting and pretty good to throw something together quickly but it's a pain when the app gets big as this one....anyways, i gotta deal with it and it'll work out fine :)
 
i'm in the process of taking over an existing software project and we're developing a new system as well using perl

Oh, then it's all right! I thought, you want only learn something new and have choosen Tcl/Tk :)

TCL is interesting and pretty good to throw something together quickly but it's a pain when the app gets big

Yes you are right! It's very innteresting language, but if you have to code in it larger programs, you will shortly discover, that it has some "hygienic" requirements on your writing style.
:)

But I can say to you from my own experience - be happy if you can learn something new, because the more you learn the better for you:
Some years ago I got a job to maintain old COBOL progs and to develop new ones. I had practice with C, Pascal, Fortran and some Unix shells before, but I never learned COBOL before.
COBOL is worse then other languages, because it has neither procedures nor functions. However it has paragraphs, but these are only like named goto-labels without local variables, i.e. all variables in program are global. And the COBOL-sources are usually very very large.
It was on the beginning real pain for me, but I learned from books and web sources and I mastered it. And to make my work easier and to do programatically what COBOL cannot do, I learned thereby the scripting languages: REXX, Python and Perl. And a short while ago I started to learn Java.
Thank to this work on the legacy software I gathered valuable experience in several fields, which caused my professional (and financial) growth.
 
Hehe yups of course, I have a big C/C++ back ground, some Pascal, delphi, php. And tcl seems to be straight forward to learn but keeping it hygienically clean is not that simple however i guess it's also plays a role what you're used to read and look at... Other languages have a very different layout.
You're talking about cobol. That reminds me strongly at my microcontroller/assembler times 10+ yeasrs ago :)
Regarding proffessional growth. I have started to look with one eye top India. Interestinmg things happening in Bangalore! India could be interesting (well not today - open the news paper on the 1st page... :O) Anyways....check out what's going on in Bangalore. There's silicon valley #2 growing up big time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top