Board index » delphi » Execute Pascal Prog from a Batch prog ?

Execute Pascal Prog from a Batch prog ?

Hi everybody!
Does anybody know how to pass a value to a constant declaration of a Pascal
Program from a Batch file? The situation I am facing is the following:

The Pascal program is having:
 const no_wei =10;
       cmi    =0.3;
 type weipointer =^warr;
      warr       =array[1..300,0..no_wei] of real;
 var  w          =weipointer;

I want to execute the pascal program changing the values of no_wei and cmi
7500 times. Therefore I am thinking of writing a batch file to call the
pascal program 7500 with different combinations of no_wei and cmi.
The problem is how to pass the values I want to the constant declaration.
Any help will be greatly appreciated.

Apostolos Romosios
University of Nottingham
Dept of Electrical and Electronic Engineering

 

Re:Execute Pascal Prog from a Batch prog ?


Hi everybody!

Quote
> Does anybody know how to pass a value to a constant declaration of a Pascal
> Program from a Batch file? The situation I am facing is the following:

I'm not sure I understood correctly - you mean the batch file gives a
number and the programme uses it? If yes then use the paramstr (no) and
convert it to a number with val.

Re:Execute Pascal Prog from a Batch prog ?


Quote
> Does anybody know how to pass a value to a constant declaration of a Pascal
> Program from a Batch file? The situation I am facing is the following:

> The Pascal program is having:
>  const no_wei =10;
>        cmi    =0.3;
>  type weipointer =^warr;
>       warr       =array[1..300,0..no_wei] of real;
>  var  w          =weipointer;

> I want to execute the pascal program changing the values of no_wei and cmi
> 7500 times. Therefore I am thinking of writing a batch file to call the
> pascal program 7500 with different combinations of no_wei and cmi.
> The problem is how to pass the values I want to the constant declaration.
> Any help will be greatly appreciated.
>    It seems you're attempting to get around the fundamental "problem" the

Pascal language has: you can't dynamically define the dimension of an
array.  Right?  If so, you're actually asking how to "edit" the program
source via parameters.  I don't know how to do that, insofar as invoking
a conventional DOS editor and doing so, but you don't have to go that
far, I believe.
   What you _can_ do, at least in TP/BP, is declare an array dimension
which is maximum possible (which uses 64K total) and work with all or
some portion of it - you don't have to use all of a declared array
dimension.  To do this, you can use the compiler to maximize the array
dimension, and you'll have to allocate and use the array on the Heap
(doing a maximum array will consume all the available Data Segment).  
Here's how to do it:

Type Max_Array = array[1..300,1..(46480 / SizeOf(Real));
                                  ^^^^^ 64K-18000
Var  W         : ^Max_Array;

   This particular exercise is tricky because your array is
2-dimensioned, and I had to subtract 18,000 ([1...300] * 6) from the 64K,
which I'm not sure was the right value.  Anyway, once you have gotten
this to compile, you can allocate W with GetMem to achieve whatever array
size you wish - within the 64K limits, of course.
   Of course, you'd also have to pass some parameters to the execution of
the program (via ParamStr)...

Re:Execute Pascal Prog from a Batch prog ?


In article <Pine.SUN.3.90.960802093821.24784B-100000@electric> of Fri, 2
Aug 1996 08:49:51 in comp.lang.pascal.borland, "<No Value Set: using

Quote
\"Apostolos Romosios\"" <a...@eee.nott.ac.uk> wrote:

>Hi everybody!
>Does anybody know how to pass a value to a constant declaration of a Pascal
>Program from a Batch file? The situation I am facing is the following:

>The Pascal program is having:
> const no_wei =10;
>       cmi    =0.3;
> type weipointer =^warr;
>      warr       =array[1..300,0..no_wei] of real;
> var  w          =weipointer;

>I want to execute the pascal program changing the values of no_wei and cmi
>7500 times. Therefore I am thinking of writing a batch file to call the
>pascal program 7500 with different combinations of no_wei and cmi.
>The problem is how to pass the values I want to the constant declaration.

cmi should be made a var and read from the parameter line.
no_wei CANNOT be altered without recompiling; but if warr is sensibly
accessed, it may be quite easy to replace no_wei in its declaration by
the biggest value you need to use and then to make no_wei a var and read
it...

There is then no meed to use the batch file, because you can modify the
Pascal to control the repeats.

See the Pascal page on my Web site, indicated in my signature --- AARGH!
where's the sig gone?  LOST - new one bodged on...
--
John Stockton, Surrey, UK.  J...@merlyn.demon.co.uk  Turnpike v1.12  MIME
     http://www.merlyn.demon.co.uk/

Re:Execute Pascal Prog from a Batch prog ?


In article <3203636C.3...@primenet.com> of Sat, 3 Aug 1996 08:22:03 in
comp.lang.pascal.borland, Mike Copeland <mrc...@primenet.com> wrote:

Quote
>Type Max_Array = array[1..300,1..(46480 / SizeOf(Real));
>                                  ^^^^^ 64K-18000
>Var  W         : ^Max_Array;

{ you mean 1800, not 18000 : 300*SizeOf(real) ? }

No;
Type Max_Array = array [1..300, 1..(65536-16) div (300*SizeOf(Real))] ;
                     { [1..300, 1..36] }
Var  W         : ^Max_Array ;
--
John Stockton, Surrey, UK.  J...@merlyn.demon.co.uk  Turnpike v1.12  MIME
     http://www.merlyn.demon.co.uk/

Re:Execute Pascal Prog from a Batch prog ?


Quote
> >Mike Copeland <mrc...@primenet.com> wrote:
> >Type Max_Array = array[1..300,1..(46480 / SizeOf(Real));
> >                                  ^^^^^ 64K-18000
> >Var  W         : ^Max_Array;
> { you mean 1800, not 18000 : 300*SizeOf(real) ? }

> No;
> Type Max_Array = array [1..300, 1..(65536-16) div (300*SizeOf(Real))] ;
>                      { [1..300, 1..36] }
> Var  W         : ^Max_Array ;
> --

   Ahhh, yes...  8<}}

Other Threads