PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Embed an IO_PROGRAM  (Read 243 times)

michaelgreer

  • Gold Member
  • ****
  • Posts: 71
    • View Profile
Embed an IO_PROGRAM
« on: April 19, 2021, 12:09:31 PM »
Is there a command line that can be used to embed an IO Program into a data file. I know this can be done with nomads, but I would like to handle it from a program.  I tinkered around with the tblinfo object and the setvalues method, but this did not seem to have any effect.

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 36
    • View Profile
Re: Embed an IO_PROGRAM
« Reply #1 on: April 19, 2021, 04:32:02 PM »
If you are looking to permanently attach the program to the data file, you will need to set it via the data dictionary. Not sure if this is the current PxPlus method, but I have used the *dict\dictionary object in the past. Below is a simple example to show how this can be done. You should enhance this with the appropriate validation and object return value verification. It is possible to update the data file with an invalid program name which would then make the file impossible to open without error. So be careful.

Code: [Select]
0010 BEGIN
0020 LET TABLENAME$="YourTableName" ! The data dictionary table name
0030 LET DB=NEW("*dict\database")
0040 IF DB'SETDATABASE("") THEN {
0050 LET T=DB'GETTABLEINFO(TABLENAME$)
0060 LET T'IOPROGRAM$="YourProgram.pvp"
0070 DB'UPDATETABLE(T) ! Update the providex.ddf data dictionary file.
0080 DB'ADJUSTTABLE(TABLENAME$) ! Update the physical file's embedded dictionary information.
0090  }
0100 DROP OBJECT DB
0110 END 

If you only need a program for temporary operation, you can use the SETDEV PROGRAM syntax.

Regards,
Jeff

michaelgreer

  • Gold Member
  • ****
  • Posts: 71
    • View Profile
Re: Embed an IO_PROGRAM
« Reply #2 on: April 20, 2021, 08:33:37 AM »
Jeff,

Thanks!  That is what I was looking for. I have inadvertently embedded a bad program before, so know the nightmare that can cause!

Michael