Problem with installing Borland C++

  • Thread starter Thread starter John Latter
  • Start date Start date
| It may be better just for 'hands-on' experience
| to start with a Basic language such as XBasic/RapidQ/BCX
| but do you know if I'll be able to create win32dll files
| with them? Can I with Python ?

John ...

There are distribution/install methods available
to convert Python source programs to stand-alone executables,
and I think you can also generate win32 DLL files
but I'm not 100% sure about that as I've never done it myself ...

Cousin JanC that often posts here could probably
shed more light on that ...

Python provides a very "basic" , e.g. fundamental, approach
to programming and the following experiment might give you
a better idea of "hands-on" type Python I/O processing ...

Although you've never used Python, I would wager
that you can read and understand the following program
that ...

o Reads an input file line-by-line
o Finds a given search string
o Writes the corresponding line
to an output file if the search string is found

Hi Cousin Stanley,

Before I get onto my understanding of the program I am (as usual)
having problems installing Python. I've posted this message to th
Python newsgroup but haven't had any reply yet:
Hi,

I downloaded Python-2.3.exe but when I used winzip it kept asking me
if I wanted to replace old files with new ones, and in some instances,
new files with old ones.

I've never downloaded/installed Python before, and as something of a
computer novice, would like to know what I may be doing wrong!

This is the link I downloaded from:


which is on this page;

http://www.python.org/2.3/

Hope someone can help!

Now to the program!
# ----------------------------------------------------------

path_in = 'c:/windows/general.txt'
path_out = 'k:/Python/py_Work/file/general_search.txt'

Looks straightforward enough - kind of 'global pointers' to the two
files that are going to be used (although if 'k' is a directory then I
haven't seen it before)
file_in = file( path_in , 'r' )
file_out = file( path_out , 'w' )

Nope - I'm having trouble even expressing why I don't understand it.
I'm looking for something that will read a line at a time, and unless
general.txt contains a number of files (each of 'n' lines) then I
don't get it.

It looks to me that file is an array pointer that goes down the
path_in and r is a command and not a variable. file_in is assigned the
current file (and not a single line as would be the case if
general.txt were one file)
search_str = 'Windows 98'

A command to search for a specified string
for this_line in file_in :

start at the first line in the file
if this_line.find( search_str ) != -1 :

file_out.write( this_line )

search_str returns -1 if the text is found so then you output it
file_in.close()
file_out.close()

these might mean the particular file has been finished so go and get
the next one - I'm not at all sure though!. I'm surprised (in my
ignorance) that there are no loop counters or tests for the last file
- if these are implicitly contained in the syntax then thats just the
way the language works I guess - but it would be nice to use one's own
error handlers if general.txt didn't meet the expected format. Just to
repeat, in case I haven't made myself very clear, the program only
makes sense to me if general_txt contains a number of files - please
show mw where I'm going wrong!

Oh and I ppresume that ! is the variable that search_str puts its
result in.

Thanks for the help Cousin Stanley!

John
# --------------------------------------------------------

Save the code between the lines above as file_find.py ...

To run the program ... python file_find.py

# ---------------------------------------------------------

The example input file, general.txt, used above
is 1354 lines ( ~41 KB ) ...

The ouput file produced 74 lines ( 3.7 KB )
with lines only containing the string 'Windows 98' ...

This program runs in about 1/10th of a second
on the 250 MHz Win98_SE machine that I use ...

--

John Latter

Model of an Internal Evolutionary Mechanism (based on an extension to homeostasis) linking Stationary-Phase Mutations to the Baldwin Effect.
http://members.aol.com/jorolat/TEM.html

'Where Darwin meets Lamarck?' Discussion Egroup
http://groups.yahoo.com/group/evomech
 
| Python is a mature and evolving language,
| under active development,...

|| Isn't that something of an oxymoron?

Cousin Programmer Dude ...

It well may be, as I'm not much
of an English language lawyer ...

Python is mature in that it's been around awhile,
since about 1991, and what is there is stable
and works well ...

It's evolving in the sense that there's always
room for improvement or extension of old features
or adding new ones while maintaining backwards
compatability with previous versions ...

Check these links for more info ...

http://www.python.org/2.3/

http://www.python.org/doc/2.3/whatsnew/
 
John Latter wrote:

Cousin Stan didn't reply, but I can make some guesses...
Now to the program!


Looks straightforward enough - kind of 'global pointers' to the two
files that are going to be used (although if 'k' is a directory
then I haven't seen it before)

I would guess they are variables that are set to the names of
those two files. K: is probably a directory on HIS system.
Nope - I'm having trouble even expressing why I don't understand it.
I'm looking for something that will read a line at a time, and
unless general.txt contains a number of files (each of 'n' lines)
then I don't get it.

I would guess both are "file open" statements that access these
files -- that is, *prepare* them for reading ('r') or writing ('w').
File open commands usually return some sort of "handle" that you
use to do the actual file operations.
A command to search for a specified string

Probably just setting another variable to the string: "Windows 98"
start at the first line in the file

The "for" statement likely reads each line in turn, setting that
line to the variable 'this_line'. Note the use of the 'file_in'
handle for file operations. (Pretty cool that the language has
a statement for file reading!)
search_str returns -1 if the text is found so then you output it

More like 'this_line' has a method (function) called find that
takes a string (search_str) as the pattern to search for.

The != means "not equal". Failure to find returns -1, success
returns something else (index to the substring, perhaps?). If
the search was successful, then, yes, output the line. Notice
that he invokes the write() method of the file_out object.
these might mean the particular file has been finished so go and
get the next one..

No, just that we're done, so close that file context we opened above.
I'm surprised (in my ignorance) that there are no loop counters
or tests for the last file...

There is no last file, just the input one and the output one.
No loop counters required, because that for statement iterates
over all lines of the file in turn.
Oh and I ppresume that ! is the variable that search_str puts
its result in.

I believe it just means "not". The bang symbol has that meaning
in a number of languages (C/C++/Java/Perl...).

Python is an object-oriented language, so you'd also need to learn
about OOP (Object Oriented Programming) to use it. Just another
element to the learning curve. In OOP languages, a common syntax
is:
object.function (arguments)

In OOP, objects "contain" their own set of functions that knows
how to manipulate their data. You invoke those functions to do
things with objects. The "." sorta means "member of", and you
will also see it used as an access operator for complex structures.

If you have a structure for a 3D point which contains x,y & z
sub-members, you might see something like:

my_point.x = 0

Which sets the x member of a given point to 0.
 
John Latter wrote:

Cousin Stan didn't reply, but I can make some guesses...


I would guess they are variables that are set to the names of
those two files. K: is probably a directory on HIS system.


I would guess both are "file open" statements that access these
files -- that is, *prepare* them for reading ('r') or writing ('w').
File open commands usually return some sort of "handle" that you
use to do the actual file operations.


Probably just setting another variable to the string: "Windows 98"


The "for" statement likely reads each line in turn, setting that
line to the variable 'this_line'. Note the use of the 'file_in'
handle for file operations. (Pretty cool that the language has
a statement for file reading!)


More like 'this_line' has a method (function) called find that
takes a string (search_str) as the pattern to search for.

The != means "not equal". Failure to find returns -1, success
returns something else (index to the substring, perhaps?). If
the search was successful, then, yes, output the line. Notice
that he invokes the write() method of the file_out object.


No, just that we're done, so close that file context we opened above.


There is no last file, just the input one and the output one.
No loop counters required, because that for statement iterates
over all lines of the file in turn.


I believe it just means "not". The bang symbol has that meaning
in a number of languages (C/C++/Java/Perl...).

Python is an object-oriented language, so you'd also need to learn
about OOP (Object Oriented Programming) to use it. Just another
element to the learning curve. In OOP languages, a common syntax
is:
object.function (arguments)

In OOP, objects "contain" their own set of functions that knows
how to manipulate their data. You invoke those functions to do
things with objects. The "." sorta means "member of", and you
will also see it used as an access operator for complex structures.

If you have a structure for a 3D point which contains x,y & z
sub-members, you might see something like:

my_point.x = 0

Which sets the x member of a given point to 0.

Hi Dude,

Its a new day and the hangover has receded sufficiently for me to bear
the sound of the keys on the keyboard being struck. Thankyou for the
explanation, yesterday I managed to get hold of a copy of "DOS for
Dummies" - its a few years out of date but still better than nothing!

I also managed to find time to start reading some of the Python Help
Notes, so Cousin Stanley's original program, along with your comments,
make more sense (whereas mine don't *g*). I came across "The != means
"not equal"" but I'm still trying to grasp some of the concepts - its
coming (but slowly). Cousin Stanley (as you probably are aware) has
got around to answer the earlier post so I'm going to zoom across and
have a look now.

John

--

John Latter

Model of an Internal Evolutionary Mechanism (based on an extension to homeostasis) linking Stationary-Phase Mutations to the Baldwin Effect.
http://members.aol.com/jorolat/TEM.html

'Where Darwin meets Lamarck?' Discussion Egroup
http://groups.yahoo.com/group/evomech
 
| I downloaded Python-2.3.exe but when I used winzip
| it kept asking me if I wanted to replace old files with new ones,
| and in some instances,new files with old ones.

You don't need to run WinZip to use the installer
as the Python installer is a self-extracting executable ...

Just double-click on the .EXE file ...

The new version I installed a couple of days ago
was named Python-2.3.exe ...

Hi Cousin Stanley,

I did finally figure it out (aka 'come to my senses') and I've been
getting a bit of grief over it on the Python newsgroup. On the
download page it says:
Windows users should download the Windows installer, Python-2.3.exe
, run it and follow the friendly instructions on the screen to complete
the installation.

and this chap said:

To which I replied, somewhat hurt, the following:
You're trying to make me look stupid.
The instructions would have been far clearer if they had said:
Windows users should download the Windows installer, Python-2.3.exe
, run it, but Whatever You Do DON'T UNZIP THE FREAKIN' THING -
This Means YOU John Latter!, and follow the friendly instructions on the screen to
complete the installation.
To make the instructions even friendlier it would also help if "but
Whatever You Do DON'T UNZIP THE FREAKIN' THING - This Means YOU John
Latter!" were in large, bold, and underlined type.
And preferably a different colour.

Hopefully that'll shut him up. Everyone makes mistakes, I just make
more than most I guess!

Anyway, on to the program.

(and I've read the first 5 pages of the Python Help Notes so I now
know what != means)
| # ----------------------------------------------------------
|
| path_in = 'c:/windows/general.txt'
| path_out = 'k:/Python/py_Work/file/general_search.txt'
|
| kind of 'global pointers' to the two files
| that are going to be used
|
| ( although if 'k' is a directory then I haven't seen it before )

I don't mind if you haven't got the time to answer all of my comments
cos there's bound to be stuff that'll become clearer once I read some
more. In the meantime however:
The important thing is that you understood
the concept of input_source_file versus
output_target_file ...

c: is a drive letter indicating the primary disk partition
on my first hard-disk drive where Windows is installed ...

k: is just another drive letter indicating a partition
on my second hard disk drive that happens to be where
my Python installation is, but I could have picked any
other one from the ones I have installed ...

[ c: d: e: f: g: h: i: j: k: l: ]

The c: partition is a single partition and is on
one hard-disk drive and the d: thru l: partitons
are all on the second hard-disk drive ...

So, the drive letters that you see and use
to locate and operate on directories and files
will depend on how your disk drives are partitioned

Most file systems are hierarchial in structure
with dirs in dirs in dirs and files within those dirs ...

The way to route yourself or a program to a particular
directory or file is to specify a PATH string to it
which on windows is comprised of a drive letter
followed by a string of dirs separated by a particular
separation character ( / ) and terminating with the
name of the file, if specifying a particular file ....

Example directory paths ...

c:/My Documents
c:/Program Files
c:/windows
c:/windows/system
j:/over_the_river/thru_the_woods/grannys_house

Example file paths ...

c:/autoexec.bat
c:/windows/general.txt
k:/Python/py_Work/file/general_search.txt
j:/over_the_river/thru_the_woods/grannys_house/apple_pie.txt


| file_in = file( path_in , 'r' )
| file_out = file( path_out , 'w' )
|
| Nope - I'm having trouble even expressing
| why I don't understand it.
| ...
Part of the reason I was having difficulty was because I didn't know
if file_in was the name you had given to a variable for clarity or
whether it was a set function - if it was a function then it wouldn't
need the 'r' instruction would it? But perhaps you never have
functions on the lefthand side (I'll have to think about this some
more - I ain't quite got it)
Object-oriented languages include concepts
that distinguish objects ( data ) and methods ( funtions )
that operate on that data ...

To apply a method to an object code it as ....

object.method()

The two file statements provide what are known
as file objects and when constructed as above
the open method is implicitly invoked on the object ....

When constructing the file objects as above,
file_in is opened in read-mode, 'r' , while
file_out is opened in write-mode, 'w' ...

The particular files that are opened have previously
been specified in the corresponding path assignments,
but the path strings can be coded in-line as well ...

file_in = file( 'c:/windows/general.txt' , 'r' )
file_out = file( 'd:/backups/general.txt' , 'w' )

The input file is a standard single text file,
just a bunch of lines of ascii text ...

Now this another reason I was confused - I actually thought of asking
if it could be coded that way and then shied away from making myself
look even more stupid (there's hope for me yet)
| search_str = 'Windows 98'
|
| A command to search for a specified string

NOT a command, but the assignment of a particular
sring value to a particular variable name ....

Pythonistas call this name-binding ...

Other strings ....

my_name = 'Stanley'
your_name = 'John'
dogs_name = 'Rover'
six_spaces = 6 * ' '

Numeric assignments ....

radius = 42
pi = 3.14159
area = pi * ( radius ** 2 )


Python also contains useful container types
which are buckets for holding other stuff
such as the list type ...

list_strs = [ my_name , your_name , dogs_name , six_spaces ]

list_nums = [ radius , pi , area ]
Yep - got the search_str = 'Windows 98' assignation now!
| for this_line in file_in :
|
| start at the first line in the file
|
Yes start at the first line of the file,
but keep going over ALL lines of the file
until end-of-file is reached ...

In Python the for statement provides one method
of looping over iterable objects ...

Block structure in Python is indicated by indentation
of the coded lines, usually indenting 4 spaces for each level ...

Example for loop that prints numbers 0 thru 9 ...

for i in range( 10 ) :
print i

Nested for loop ....

for i in range( 5 ) :
for j in range( 10 ) :
print i , j

Print items from a list ....

for this_str in list_strs :
print this_str

for this_num in list_nums :
print this_num

So, the this_whatEver I've shown here
means the current value of the object
on THIS particular pass thru the loop ....

Part of the Python magic when using file objects
is that they are iterable, so to print an entire file ...

for this_line in file_in :
print this_line


| if this_line.find( search_str ) != -1 :
|
| search_str returns -1 if the text is found

Almost ...

The method find() applied to the object this_line
using the value of the argument search_str
returns -1 if NOT found ...

So, if you do find what you're looking for
the returned value is NOT -1 ....

| so then you output it

Yes, by applying the write() method
to the file_out object using the current value
of the argument this_line ....

file_out.write( this_line )


| file_in.close()
| file_out.close()
|
| these might mean the particular file has been finished
| so go and get the next one

Yes, these lines mean we are finished
with both the input file and the output file,
now close them ...

However, we are finished with everything at this point
and there are NO other files in this program to go to ...

| I'm not at all sure though!. I'm surprised ( in my ignorance )
| that there are no loop counters or tests for the last file
|
| if these are implicitly contained in the syntax then
| thats just the way the language works I guess -
|

In Python the file iterators are seemingly magic
since they are implicit in the object construction
and can be iterated over with a simple for loop ...

aFile = file( 'anyOleFile.txt' , 'r' )

for aLine in aFile :
print aLine

That's it ... everything needed to loop over
the entire file ...


| but it would be nice to use one's own error handlers
| if general.txt didn't meet the expected format.
|
Python includes standard methods to deal with errors,
referred to as Exception Handling ...

import os , sys

path_in = 'g:/graphics/somePic.gif'

try :

file_in = file( path_in , 'r' )

except :

print 'Error opening input file' , path_in

sys.exit( -1 )


| Just to repeat, in case I haven't made myself very clear,
| the program only makes sense to me if general_txt contains
| a number of files - please show me where I'm going wrong!

c:/windows/general.txt is a SINGLE text file ...

Only ASCII characters with each line ending
with the new-line character '\n'


| Oh and I ppresume that ! is the variable
| that search_str puts its result in.

For testing equality, Python if statements
use double equal signs :

this_name = 'Rumplestilskin'

if this_name == 'Stanley' :
print 'Greetings, Stanley ...'

elif this_name == 'John' :
print 'Greetings, John ...'

elif this_name == 'Rumplestilskin' :
print 'Yo, Rumple Dude ...'


The two-character sequence != in Python if statements
means NOT-EQUAL ....

if this_name != 'Rumplestilskin' :
print 'You know nothing about spinning straw into gold'


| Thanks for the help Cousin Stanley!

You're welcome ...

Hope I haven't confused you too much
and that you do give Python a good whirl ....

Look at the code again to see if it now
seems a bit more clear ....

I intend to have a good look at Python but I've run out of time for
now and have to rush off. Thankyou again Cousin Stanley, the program
is clearer, and in conjunction with reading the Help Notes and the
examples included there, I'm sure that things will become clearer
still.

Gotta zoom off but I hope you'll keep your eye out for any posts about
Python where you'll be able to help!

John
# The pound sign is the Python comment character

# Assign path string values to variable names

path_in = 'c:/windows/general.txt'
path_out = 'c:/someOtherDir/general.txt'

# Construct file objects and implicitly open files

file_in = file( path_in , 'r' )
file_out = file( path_out , 'w' )

# Assign the value of s string to search for

search_str = 'Windows 98'

# Loop over lines in the input file line-by-line
# No counters or EOF checks needed since file objects
# are iterable, Python magic ...

+--> for this_line in file_in :
|
| if this_line.find( search_str ) != -1
|
+----------- file_out.write( this_line )

# We're done, close the files
# by applying the close() method
# to the file objects

file_in.close()
file_out.close()

--

John Latter

Model of an Internal Evolutionary Mechanism (based on an extension to homeostasis) linking Stationary-Phase Mutations to the Baldwin Effect.
http://members.aol.com/jorolat/TEM.html

'Where Darwin meets Lamarck?' Discussion Egroup
http://groups.yahoo.com/group/evomech
 
John said:
I've been getting a bit of grief over it on the Python newsgroup.

amUSENET requires a fairly thick skin. The safety of the keyboard
seems to give people lease to explore the boundaries of rudeness
and thoughtlessness.
 
amUSENET requires a fairly thick skin. The safety of the keyboard
seems to give people lease to explore the boundaries of rudeness
and thoughtlessness.

Hi Dude,

I certainly know what you mean but I've been pretty lucky so far I
guess.

!'m making progress with Python (in particular) & the various Basic
languages but am disappointed that achieving the status of
TECHNOdemi(*)GOD make take longer than the 45 minutes I originally
allocated. Never mind, I'm committed now :)

(*optional)

--

John Latter

Model of an Internal Evolutionary Mechanism (based on an extension to homeostasis) linking Stationary-Phase Mutations to the Baldwin Effect.
http://members.aol.com/jorolat/TEM.html

'Where Darwin meets Lamarck?' Discussion Egroup
http://groups.yahoo.com/group/evomech
 
Back
Top