From:	SMTP%"everhart@star.zko.dec.com"  1-OCT-1996 18:29:40.92
To:	EVERHART
CC:	
Subj:	FinaI: Is there a line editor I can use from a DCL command p - comp.os.vms #156212

Date: Tue, 1 Oct 1996 15:49:31 -0400
Message-Id: <96100115493116@star.zko.dec.com>
From: everhart@star.zko.dec.com (Glenn C. Everhart 603 881 1497)
To: everhart@gce.com
Subject: FinaI: Is there a line editor I can use from a DCL command p - comp.os.vms #156212
X-VMS-To: smtp%"everhart@gce.com"

In article <96Oct1.145308gmt+0100.23053@firewall.bang-olufsen.dk>, "Hans-Peter Harpoeth" <hph@bang-olufsen.dk> writes:
I wrote:

> Hello
>
>   Is there a line editor I can use within a DCL command procedure, to let
>   the user _edit_ the content of a string symbol?
<cut...>

Thanks for many replies !
Maybe I wasn't clear enough. I did mean _edit_ the symbol, not reenter whic=
h was
suggested in many replies.

Especially thanks to Phillip Helbig who lead me in the right direction.

My solution is now a tiny C program:


/* EDIT_SYMBOL.C */
/*
   This program reads the specified environment variable,
   display's the variable for editing and writes it back
   to a local symbol with the same name as the environment variable.

   Usage:
   $ edit_symbol=3D "$<device>:[<directory>]edit_symbol"
   $ test_symbol=3D "Default value."
   $ edit_symbol "Prompt string: " "TEST_SYMBOL"
   $ show symbol test_symbol
*/

#include descrip

#define check(stat) if ((stat&1) !=3D 1) exit(stat)

char string_value[255];
$DESCRIPTOR(string_value_d, string_value);

char prompt[255];
$DESCRIPTOR(prompt_d, prompt);

char default_string[255];
$DESCRIPTOR(default_string_d, default_string);

char symbol_name[255];
$DESCRIPTOR(symbol_name_d,symbol_name);

main(int argc, char *argv[])
{
  int ikbd,iret;
  int max_length=3D 255;
  int value_length;

  /* Open virtual keyboard */
  iret =3D SMG$CREATE_VIRTUAL_KEYBOARD(&ikbd);
  check(iret);

  /* Read in symbol value */
  if (argc>2)
  {
    strcpy(prompt,argv[1]);
    prompt_d.dsc$w_length=3D strlen(prompt);
    strcpy(symbol_name,argv[2]);
    symbol_name_d.dsc$w_length=3D strlen(symbol_name);
  }
  else
  {
    puts("Usage: $edit_symbol \"Prompt string: \" \"TEST_SYMBOL\"");
    exit(3);
  }
  strcpy(default_string,getenv(symbol_name));
  default_string_d.dsc$w_length=3D strlen(default_string);

  iret =3D SMG$READ_STRING(&ikbd, &string_value_d,
&prompt_d,&max_length,0,0,0,&value_length,0,0,&default_string_d);
  check(iret);

  string_value_d.dsc$w_length =3D value_length;
  iret=3D lib$set_symbol (&symbol_name_d,&string_value_d);
  check(iret);
}



        Regards Hans-Peter

 --

 Hans-Peter Harpoeth  BB     &     OOO
 SW development       B B   & &   O   O  Phone : +45 96 84 49 85
 Bang & Olufsen       BBBB   &&   O   O    or  : +45 96 84 11 22
 Peter Bangs Vej 15   B   B &  && O   O  Fax   : +45 97 85 59 50
 DK-7600 Struer       B   B &  && O   O  email : hph(a)bang-olufsen.dk
 Denmark              BBBB   &&    OOO





