FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour pass parameters from bat to pgm
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
pass parameters from bat to pgm
Posted: 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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: pass parameters from bat to pgm
Posted: 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:

set cValue=1

  1. 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:

set cValue=1

psql -f mio.pgm -v cvalue=%cValue%

  1. 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:

-- 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

Continue the discussion