Turbo 16 bit program for AUTOEXEC.BAT 
Author Message
 Turbo 16 bit program for AUTOEXEC.BAT

hello, I'm hoping someone can help.  I need to run a program at startup
on a Win95 PC to modify an INI file.

I have written a console app in Delphi, and this does the job fine.  The
problem is it will not run from the AUTOEXEC.BAT - "This program must be
run under Win32".  It seems anything run in autoexec.bat must be an old
fashioned 16bit real mode program.  Wish I knew this before I wrote the
{*filter*}y thing - works fine on my "virtual windows PC" under linux...

AFAIK it is not possible to recompile this source code for a 16-bit
target - if this is possible that would be ideal.  From what I can
gather I need to use an old 16 bit compiler, and rewrite my code
accordingly.

The only Pascal compiler I can see which produces real DOS programs (and
is free) is Borland Turbo Pascal 5.5.  I've downloaded it, but I think I
need some help.

I'm assuming there are not going to be any helpful tools specific to INI
files, so I'm approaching this as a simple ASCII text editing operation.
  Anyone have any sample code for opening, editing, saving and /or
closing a text file with Turbo Pascal 5.5?

Anyone who can suggest another way to generate a 16 bit program, please
tell me.  Are 16 bit version of delphi available anywhere, for example?
  Or perhaps a program similar to quickbasic?  I used to use BASIC in
the 80s, my pascal experience is all more modern, with objectpascal
(Delphi 3,4,5,6,7).  I am hopeless at C.

Any help gratefully accepted.

Woody.

BTW I know I could set the program to run after windows startup with the
registry key using the "ms\windows\current version\run", but I really
want it to run before all other programs, and AUTOEXEC.BAT is the
natural choice.



Mon, 25 Apr 2005 21:35:53 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT


Quote:
>AFAIK it is not possible to recompile this source code for a 16-bit
>target - if this is possible that would be ideal.  From what I can
>gather I need to use an old 16 bit compiler, and rewrite my code
>accordingly.

If you target 16-bit DOS mode instead of Win3x, this is possible and should
be fairly easy to do.  I don't know if Delphi allows this, as I've never
used it.

Quote:
>I'm assuming there are not going to be any helpful tools specific to INI
>files, so I'm approaching this as a simple ASCII text editing operation.

You are correct--the Windows API will not be available to you

Quote:
>  Anyone have any sample code for opening, editing, saving and /or
>closing a text file with Turbo Pascal 5.5?

The venerable SWAG collection (http://www.gdsoft.com/swag/swag.html) should
have several INI units that ape the Windows INI API functions
GetProfileString, WriteProfileString, etc.

--
Robert B. Clark (email ROT13'ed)
Visit ClarkWehyr Enterprises On-Line at http://www.3clarks.com/ClarkWehyr/



Tue, 26 Apr 2005 00:30:20 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT



Quote:
> hello, I'm hoping someone can help.  I need to run a program at startup
> on a Win95 PC to modify an INI file.

> I have written a console app in Delphi, and this does the job fine.
The
> problem is it will not run from the AUTOEXEC.BAT - "This program must
be
> run under Win32".  It seems anything run in autoexec.bat must be an old
> fashioned 16bit real mode program.  Wish I knew this before I wrote the
> {*filter*}y thing - works fine on my "virtual windows PC" under linux...

> AFAIK it is not possible to recompile this source code for a 16-bit
> target - if this is possible that would be ideal.  From what I can
> gather I need to use an old 16 bit compiler, and rewrite my code
> accordingly.

> The only pascal compiler I can see which produces real DOS programs
(and
> is free) is Borland Turbo Pascal 5.5.  I've downloaded it, but I think
I
> need some help.

At www.borland.fr you can download the french version of TP 7.0

Quote:
> I'm assuming there are not going to be any helpful tools specific to
INI
> files, so I'm approaching this as a simple ASCII text editing
operation.
>   Anyone have any sample code for opening, editing, saving and /or
> closing a text file with Turbo Pascal 5.5?

Is it only the opening editing and saving?
If so I would advice you to open the text file using the dos editor
EDIT.COM
Normally you will find it in the C:\windows\command   directory.
So in the autoexec.bat a line

C:\windows\command\edit  myfile.ini

would do the trick.
If you want to call it from a pascal program

      swapvectors;
      Exec(GetEnv('COMSPEC'), '/C edit.com myfile.ini);
      swapvectors;

- Show quoted text -

Quote:
> Anyone who can suggest another way to generate a 16 bit program, please
> tell me.  Are 16 bit version of delphi available anywhere, for example?
>   Or perhaps a program similar to quickbasic?  I used to use BASIC in
> the 80s, my pascal experience is all more modern, with objectpascal
> (Delphi 3,4,5,6,7).  I am hopeless at C.

> Any help gratefully accepted.

> Woody.

> BTW I know I could set the program to run after windows startup with
the
> registry key using the "ms\windows\current version\run", but I really
> want it to run before all other programs, and AUTOEXEC.BAT is the
> natural choice.

That would have been my other suggestion, to put your Delphi program in
the windows startup directory

C:\windows\start menu\programs\start up

(Depends on what language)

Femme



Tue, 26 Apr 2005 00:31:22 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT
Hello!

You just downloaded Borlands first TP compiler which had Object
Orientation build in! The advice to get the SWAG is also very helpfull.
If you do speak french (at least to some degree), you might consider to
use the free french TP 7.0 since it comes with a much more advanced help
system than TP 5.5.

For opening a text file you would use ASSIGN and RESET to close it CLOSE
and READLN to read from it. APPEND, WRITE  and REWRITE can be very handy
for you too... ;-)

Greetings

Markus



Tue, 26 Apr 2005 03:01:55 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:

> Hello!

> You just downloaded Borlands first TP compiler which had Object
> Orientation build in! The advice to get the SWAG is also very helpfull.
> If you do speak french (at least to some degree), you might consider to
> use the free french TP 7.0 since it comes with a much more advanced help
> system than TP 5.5.

> For opening a text file you would use ASSIGN and RESET to close it CLOSE
> and READLN to read from it. APPEND, WRITE  and REWRITE can be very handy
> for you too... ;-)

> Greetings

> Markus

Yeah, I noticed it has some OO example programs.  Still, this is
possibly overkill for such a simple program - it is a simple open file,
search and replace known text values, save file operation.

I can read French a little, so maybe I'll give TP7 a go.  I could use
better help at least.

Thanks for the pointers on some of the commands I might need to use.

Woody.



Tue, 26 Apr 2005 16:40:59 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:

> At www.borland.fr you can download the french version of TP 7.0

I'm not sure TP7 is really needed, since my program is really very
simple.  Maybe I will find the earlier version easier to learn?
However, I will try it - I'm told the help is better.

Quote:

> Is it only the opening editing and saving?
> If so I would advice you to open the text file using the dos editor
> EDIT.COM
> Normally you will find it in the C:\windows\command   directory.
> So in the autoexec.bat a line

> C:\windows\command\edit  myfile.ini

> would do the trick.
> If you want to call it from a pascal program

>       swapvectors;
>       Exec(GetEnv('COMSPEC'), '/C edit.com myfile.ini);
>       swapvectors;

> Femme

Thanks for this technique, however, I need the
program to search for a set of known values and
replace them automatically.


Tue, 26 Apr 2005 16:45:59 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:



>>AFAIK it is not possible to recompile this source code for a 16-bit
>>target - if this is possible that would be ideal.  From what I can
>>gather I need to use an old 16 bit compiler, and rewrite my code
>>accordingly.

> If you target 16-bit DOS mode instead of Win3x, this is possible and should
> be fairly easy to do.  I don't know if Delphi allows this, as I've never
> used it.

>>I'm assuming there are not going to be any helpful tools specific to INI
>>files, so I'm approaching this as a simple ASCII text editing operation.

> You are correct--the Windows API will not be available to you

>> Anyone have any sample code for opening, editing, saving and /or
>>closing a text file with Turbo Pascal 5.5?

> The venerable SWAG collection (http://www.gdsoft.com/swag/swag.html) should
> have several INI units that ape the Windows INI API functions
> GetProfileString, WriteProfileString, etc.

Thanks for the help.  Like I say, I'm pretty sure I can't target 16 bit
DOS as a compiler option - the compiler seems to be 32 bit only (which
is fair enough really). I will check out the SWAG collection, I was not
aware of it.

Woody.



Tue, 26 Apr 2005 16:49:15 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:

> hello, I'm hoping someone can help.  I need to run a program at startup
> on a Win95 PC to modify an INI file.

> I have written a console app in Delphi, and this does the job fine.  The
> problem is it will not run from the AUTOEXEC.BAT - "This program must be
> run under Win32".  It seems anything run in autoexec.bat must be an old
> fashioned 16bit real mode program.

Not true. It must interface to Dos, and the interface must be realmode. A
16-bit or 32-bit protected mode program with extender would also do the
trick.

Options:
- Free Pascal (www.freepascal.org),
  pro: - has a classes based .INI classes
       - supports 32-bit protected mode dos.
       - supports object Pascal.
  con: - Is protected mode (slightly larger .exe's + 200 kb extender)
  (when:if you use a lot of Delphi language, or a Delphi compatible INI classes
   unit makes it a lot easier)
  The FPC ini unit looks like this:
 http://www.freepascal.org/cgi-bin/cvsweb/~checkout~/fpc/fcl/inc/inifi...

- 32-bit Delphi with WDosX (windows emulating dos extender)
  Pro: - least work in theory. Supports quite a lot of base win32 calls,
         so specially if you use win32 calls directly it could be of some
         use.
       - Can work with Delphi which you know already.
  Con: - WDosX procedure of binary creation might require wizard skills (not
         many people take this traject, therefore I _assume_ it is difficult,
         don't know for sure)
       - Not 100% if the wdosx extender works under plain dos.
  Searching for wdosx + delphi will certainly give hits.
  (when: if you use a lot of win32 functions that are supported by win32)

- BP/TP
        pro: - 16-bit realmode, slightly quicker startup time, smallest exe
                 (think 1 sec startup time and 10-30 kb instead of 100 kb+
                 200 kb extender)
        con: - Not Delphi dialect
             - ini handling unit (when found, I also think there are in
               SWAG) will be less Delphi like. The SWAG routines are probably
               meant for 16-bits windows, which might slightly differ from
               the w9x and NT family INI libraries.

Quote:
> AFAIK it is not possible to recompile this source code for a 16-bit
> target - if this is possible that would be ideal.

That depends on the contents also. 16-bit (which is not necessary,
see above) probably won't be the problem, but TP will force you to use
the TP, not Delphi dialect (admitted, not that far apart, again the importance
of that depends on application)

Quote:
>  From what I can
> gather I need to use an old 16 bit compiler, and rewrite my code
> accordingly.

No. You need a real dos exe. Doesn't matter if it is 16-bit, _OR_ if your
program

Quote:
> The only pascal compiler I can see which produces real DOS programs (and
> is free) is Borland Turbo Pascal 5.5.  I've downloaded it, but I think I
> need some help.

True (except TP7 french), but that Dos runs in real mode mostly itself,
doesn't force the applications to be in realmode. (compare: windows NT runs
in protected mode, and allows real mode program execution)

Quote:
> Anyone who can suggest another way to generate a 16 bit program, please
> tell me.  Are 16 bit version of delphi available anywhere, for example?
>   Or perhaps a program similar to quickbasic?  I used to use BASIC in
> the 80s, my pascal experience is all more modern, with objectpascal
> (Delphi 3,4,5,6,7).  I am hopeless at C.

Primarily use FPC, it is a 32-bit Object Pascal compiler with full dos
support.

Using a different extender like tricks to get to dos, are afaik also
possible for Delphi1, but I think then the 32-bit approach would be easier
in that case.



Tue, 26 Apr 2005 18:34:07 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT
I can't find TB7 on www.borland.fr - anyone know the exact url?
Quote:



>>hello, I'm hoping someone can help.  I need to run a program at startup
>>on a Win95 PC to modify an INI file.

>>I have written a console app in Delphi, and this does the job fine.

> The

>>problem is it will not run from the AUTOEXEC.BAT - "This program must

> be

>>run under Win32".  It seems anything run in autoexec.bat must be an old
>>fashioned 16bit real mode program.  Wish I knew this before I wrote the
>>{*filter*}y thing - works fine on my "virtual windows PC" under linux...

>>AFAIK it is not possible to recompile this source code for a 16-bit
>>target - if this is possible that would be ideal.  From what I can
>>gather I need to use an old 16 bit compiler, and rewrite my code
>>accordingly.

>>The only pascal compiler I can see which produces real DOS programs

> (and

>>is free) is Borland Turbo Pascal 5.5.  I've downloaded it, but I think

> I

>>need some help.

> At www.borland.fr you can download the french version of TP 7.0

>>I'm assuming there are not going to be any helpful tools specific to

> INI

>>files, so I'm approaching this as a simple ASCII text editing

> operation.

>>  Anyone have any sample code for opening, editing, saving and /or
>>closing a text file with Turbo Pascal 5.5?

> Is it only the opening editing and saving?
> If so I would advice you to open the text file using the dos editor
> EDIT.COM
> Normally you will find it in the C:\windows\command   directory.
> So in the autoexec.bat a line

> C:\windows\command\edit  myfile.ini

> would do the trick.
> If you want to call it from a pascal program

>       swapvectors;
>       Exec(GetEnv('COMSPEC'), '/C edit.com myfile.ini);
>       swapvectors;

>>Anyone who can suggest another way to generate a 16 bit program, please
>>tell me.  Are 16 bit version of delphi available anywhere, for example?
>>  Or perhaps a program similar to quickbasic?  I used to use BASIC in
>>the 80s, my pascal experience is all more modern, with objectpascal
>>(Delphi 3,4,5,6,7).  I am hopeless at C.

>>Any help gratefully accepted.

>>Woody.

>>BTW I know I could set the program to run after windows startup with

> the

>>registry key using the "ms\windows\current version\run", but I really
>>want it to run before all other programs, and AUTOEXEC.BAT is the
>>natural choice.

> That would have been my other suggestion, to put your Delphi program in
> the windows startup directory

> C:\windows\start menu\programs\start up

> (Depends on what language)

> Femme



Tue, 26 Apr 2005 19:48:30 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:

>>hello, I'm hoping someone can help.  I need to run a program at startup
>>on a Win95 PC to modify an INI file.

>>I have written a console app in Delphi, and this does the job fine.  The
>>problem is it will not run from the AUTOEXEC.BAT - "This program must be
>>run under Win32".  It seems anything run in autoexec.bat must be an old
>>fashioned 16bit real mode program.

> Not true. It must interface to Dos, and the interface must be realmode. A
> 16-bit or 32-bit protected mode program with extender would also do the
> trick.

> Options:
> - Free Pascal (www.freepascal.org),
>   pro: - has a classes based .INI classes
>        - supports 32-bit protected mode dos.
>        - supports object Pascal.
>   con: - Is protected mode (slightly larger .exe's + 200 kb extender)
>   (when:if you use a lot of Delphi language, or a Delphi compatible INI classes
>    unit makes it a lot easier)
>   The FPC ini unit looks like this:
>  http://www.freepascal.org/cgi-bin/cvsweb/~checkout~/fpc/fcl/inc/inifi...

> - 32-bit Delphi with WDosX (windows emulating dos extender)
>   Pro: - least work in theory. Supports quite a lot of base win32 calls,
>     so specially if you use win32 calls directly it could be of some
>     use.
>        - Can work with Delphi which you know already.
>   Con: - WDosX procedure of binary creation might require wizard skills (not
>     many people take this traject, therefore I _assume_ it is difficult,
>     don't know for sure)
>        - Not 100% if the wdosx extender works under plain dos.
>   Searching for wdosx + delphi will certainly give hits.
>   (when: if you use a lot of win32 functions that are supported by win32)

> - BP/TP
>    pro: - 16-bit realmode, slightly quicker startup time, smallest exe
>             (think 1 sec startup time and 10-30 kb instead of 100 kb+
>             200 kb extender)
>    con: - Not Delphi dialect
>         - ini handling unit (when found, I also think there are in
>           SWAG) will be less Delphi like. The SWAG routines are probably
>           meant for 16-bits windows, which might slightly differ from
>           the w9x and NT family INI libraries.

>>AFAIK it is not possible to recompile this source code for a 16-bit
>>target - if this is possible that would be ideal.

> That depends on the contents also. 16-bit (which is not necessary,
> see above) probably won't be the problem, but TP will force you to use
> the TP, not Delphi dialect (admitted, not that far apart, again the importance
> of that depends on application)

>> From what I can
>>gather I need to use an old 16 bit compiler, and rewrite my code
>>accordingly.

> No. You need a real dos exe. Doesn't matter if it is 16-bit, _OR_ if your
> program

>>The only pascal compiler I can see which produces real DOS programs (and
>>is free) is Borland Turbo Pascal 5.5.  I've downloaded it, but I think I
>>need some help.

> True (except TP7 french), but that Dos runs in real mode mostly itself,
> doesn't force the applications to be in realmode. (compare: windows NT runs
> in protected mode, and allows real mode program execution)

>>Anyone who can suggest another way to generate a 16 bit program, please
>>tell me.  Are 16 bit version of delphi available anywhere, for example?
>>  Or perhaps a program similar to quickbasic?  I used to use BASIC in
>>the 80s, my pascal experience is all more modern, with objectpascal
>>(Delphi 3,4,5,6,7).  I am hopeless at C.

> Primarily use FPC, it is a 32-bit Object Pascal compiler with full dos
> support.

> Using a different extender like tricks to get to dos, are afaik also
> possible for Delphi1, but I think then the 32-bit approach would be easier
> in that case.

Thanks Marco.  I accept what you say about 16/32 bit stuff, I am not an
expert having never really coded for DOS (except dBaseIII !).

Because this program should be very straightforward, adding a DOS
extender into the mix is not ideal - I'd prefer the smaller filesize.

I'm keen to look at TP7, but this seems to no longer be available from
borland.fr. Is this available from any other source? (Has any kind soul
posted it on their own ftp server?)

I might have a look at free pascal in any case, as I am interested to
see if I can use it for writing native linux apps.  Kylix apps seem to
be not very portable....

Woody.



Tue, 26 Apr 2005 21:12:11 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:

>> Using a different extender like tricks to get to dos, are afaik also
>> possible for Delphi1, but I think then the 32-bit approach would be easier
>> in that case.

> Thanks Marco.  I accept what you say about 16/32 bit stuff, I am not an
> expert having never really coded for DOS (except dBaseIII !).

> Because this program should be very straightforward, adding a DOS
> extender into the mix is not ideal - I'd prefer the smaller filesize.

> I'm keen to look at TP7, but this seems to no longer be available from
> borland.fr. Is this available from any other source? (Has any kind soul
> posted it on their own ftp server?)

It was only legally on the French site. (in the french language also), but
at the time it was at inprise.fr somewhere.

But I use FPC now, I mainly bought BP7 for the Turbo Vision license, and
for possible future 16-bit embedded stuff.

Quote:
> I might have a look at free pascal in any case, as I am interested to
> see if I can use it for writing native linux apps.

It works fine, and also under BSD and a few other platforms. (including one
non intel processor, a number we hope to expand soon)

But GUI programs can be harder than under Kylix. ( Lazarus.freepascal.org is
trying to do something about that).

Quote:
> Kylix apps seem to be not very portable....

Maybe it will get better in time, but OTOH the versions are all so close
lately. I don't want to spend Eur 999 on compilers several times a year.

P.s. for more FPC questions please use NG comp.lang.pascal.misc



Tue, 26 Apr 2005 22:02:45 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT


Quote:



>>> Anyone have any sample code for opening, editing, saving and /or
>>>closing a text file with Turbo Pascal 5.5?

Assign, Rewrite, Reset, Open, Writeln, Readln, and Close should be enough
to get you started. :-)

For a specialized application such as yours (seeking and editing a line in
an INI file), all you need do is open the INI file and examine each line in
turn, modifying as necessary:

        open source_ini for reading;
        open temp_file for writing;

        do
                read line from source_ini
                needs modification?
                        yes -- modify line
                write line to temp_file
        repeat until eof(source_ini)

        close source_ini
        close temp_file
        copy temp_file over source_ini
        delete temp_file

You can dispense with most of the functionality of the Windows INI API such
as caching the INI file, supplying data I/O functions, etc., unless you
wish to write a more generalized (and useful) unit.

Quote:
>> The venerable SWAG collection (http://www.gdsoft.com/swag/swag.html) should
>> have several INI units that ape the Windows INI API functions
>> GetProfileString, WriteProfileString, etc.

>Thanks for the help.  Like I say, I'm pretty sure I can't target 16 bit
>DOS as a compiler option - the compiler seems to be 32 bit only (which

Assuming you mean Delphi?  TP 5.5 is a real-mode compiler.

Quote:
>is fair enough really). I will check out the SWAG collection, I was not
>aware of it.

Several of the solutions in SWAG are OO and require TP 7 (maybe 6?);
however you should be able to rewrite them easily enough for use with TP
5.5, especially if you choose to not implement the more generalized
functionality.

--
Robert B. Clark (email ROT13'ed)
Visit ClarkWehyr Enterprises On-Line at http://www.3clarks.com/ClarkWehyr/



Tue, 26 Apr 2005 23:55:21 GMT  
 Turbo 16 bit program for AUTOEXEC.BAT

Quote:






>>>>Anyone have any sample code for opening, editing, saving and /or
>>>>closing a text file with Turbo Pascal 5.5?

> Assign, Rewrite, Reset, Open, Writeln, Readln, and Close should be enough
> to get you started. :-)

> For a specialized application such as yours (seeking and editing a line in
> an INI file), all you need do is open the INI file and examine each line in
> turn, modifying as necessary:

>    open source_ini for reading;
>    open temp_file for writing;

>    do
>            read line from source_ini
>            needs modification?
>                    yes -- modify line
>            write line to temp_file
>    repeat until eof(source_ini)

>    close source_ini
>    close temp_file
>    copy temp_file over source_ini
>    delete temp_file

> You can dispense with most of the functionality of the Windows INI API such
> as caching the INI file, supplying data I/O functions, etc., unless you
> wish to write a more generalized (and useful) unit.

>>>The venerable SWAG collection (http://www.gdsoft.com/swag/swag.html) should
>>>have several INI units that ape the Windows INI API functions
>>>GetProfileString, WriteProfileString, etc.

>>Thanks for the help.  Like I say, I'm pretty sure I can't target 16 bit
>>DOS as a compiler option - the compiler seems to be 32 bit only (which

> Assuming you mean Delphi?  TP 5.5 is a real-mode compiler.

yes!

Quote:

>>is fair enough really). I will check out the SWAG collection, I was not
>>aware of it.

> Several of the solutions in SWAG are OO and require TP 7 (maybe 6?);
> however you should be able to rewrite them easily enough for use with TP
> 5.5, especially if you choose to not implement the more generalized
> functionality.

There are some handy looking items in SWAG.

There are some units which look to provide the type of ini file methods
I'm used to, but I'm unclear if they work with TP5.5.  I will probably
use a more generic text editing approach.  Your design seems about right.

thanks for your help,

Woody.



Wed, 27 Apr 2005 00:56:44 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Calling 16 bit Dll from 32 bit program

2. 16-bit sound on Sound Blaster in Turbo Pascal

3. Delphi (16-Bit) and OCI programming

4. Help: convert 16 bit program to 32 !

5. Convert 32 bit component to 16 bit ??

6. BDE 32-bit & 16-bit

7. 16 bit ODBC drivers in the 32 bit environment

8. 32 bit bde with 16 bit odbc

9. CRC 16-bit and 32-bit

10. Delphi/BDE 16 bit VS 32 bit

11. Upgrade 16-bit application to 32-bit

12. Upgrade 16-bit application to 32-bit

 

 
Powered by phpBB® Forum Software