pass parameters from bat to pgm

pass parameters from bat to pgm

Postby damianodec » Tue Sep 03, 2024 10:14 am

hi,
how can I to read in my .pgm a value that I have in my .bat file?

Example:
inside file mio.bat
set cValue="1"

inside file mio.pgm
instruction that read cValue of mio.bat

thanks
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 418
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: pass parameters from bat to pgm

Postby Antonio Linares » Tue Sep 03, 2024 10:32 am

To read a value from a .bat file into a .pgm file, you'll need to use a combination of batch scripting and PostgreSQL commands. Here's a step-by-step approach:

1. First, in your .bat file (mio.bat), set the value:

```batch
set cValue=1
```

2. Then, you need to pass this value to your PostgreSQL script. You can do this by using environment variables. Modify your .bat file to call the .pgm file and pass the variable:

```batch
set cValue=1
psql -f mio.pgm -v cvalue=%cValue%
```

3. In your .pgm file (mio.pgm), you can now access this value using the `:cvalue` syntax. Here's an example of how you might use it:

```sql
-- mio.pgm
SELECT :cvalue AS imported_value;
```

This will create a query that selects the value passed from the .bat file.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42048
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 31 guests