Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/How-would-you-go-about-this.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
How would you go about this?

Posted by Avarice (Avarice), 1 August 2003
Alright theres this file that contains data for 3 graphs we'll call this file graph.plot  Within is file is hundreds of numbers.  On my interface i have a button and when i press it, it goes to a procedure that reads the file using
set copy [open copy.plot w]
set eval [open graph.plot r]
foreach line {split [read $eval] \n} {
puts $copy $line
}
Alright when i save what is read to another file and open it with unix,  not all the data is read and put ont copy.plot how do i make sure that everything is read?

ALSO how do i go about searching through the data that is read.  In graph.plot the first 2 graphs are currently meaningless, thus there are hundreds of numbers that i dont' need.  However, the final third of graph.plot have very vital numbers to me.  I need to go in and find the domain of the graph and find the max and min.  However, i don't know how to skip through what is read and get to that part of the file to do commands on those numbers.  Any suggestions/do you even know what i'm talking about?

Posted by admin (Graham Ellis), 2 August 2003
First question.

Answer - you should have square brackets and not curly braces around trhe split, as it's a command to be run.  I tested your code - my output file contained the code in the { } s (21 bytes) until I replaced them with [ and ], when it leapt to being 1 byte LONGER than the incoming file.

The \n on the very end of the incoming data file causes an empty string to be added as the list element of the list that split generates, giving an empty line on the outgoing file end.  use the -nonewline option on read to supress the reading of the final new line.  If you can't be certain that there will be a new line on the end of your data, and you can't allow an extra blank line to be added in any circumstances, you'll need to add an extra check.

Finally, if you're going on to read your data from the copy (in the same program), close the file before you open a fresh handle to do the read - that way, you'll ensure that any buffers are flushed to disc.

With regards skipping through the the start of the file ... how do YOU recognise where the unwanted data ends and the wanted data begins?   Set a variable to 0 before you start your copy loop, then test each line to see if it's the boundary condition, and if it is set that variable to 1.   Only output lines to the output file if this state variable has the value 1 ....



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho