Menu

#21 variables in actions

v1.0 (example)
open
nobody
None
5
2021-11-15
2021-11-13
Sardonimous
No

Is there a was to use variables (environment variables, for example) in actions?
I have to connect to various different clients that provide me different userids. I'd like to be able to set an environment variable,
export X3270USER=MYID
then use that variable in a keymap or hosts file connection String() action,
String("PROFILE PREFIX("$X3270USER")")
or something like that.

Discussion

  • Sardonimous

    Sardonimous - 2021-11-13

    One way I did find to get what I need in a keymap is to use the -xrm option.

    x3270 -xrm 'x3270.keymap.CLIENTA: #override Alt<key>U: String("PROFILE PREFIX(MYID)")' -xrm 'x3270.keymap: CLIENTA' clienta.com</key>

    A bit kludgy I think.

     
  • Paul Mattes

    Paul Mattes - 2021-11-15

    Support for this was added a week or two back. It's not in a tagged release, but if you build from the head of the master branch, you will get it.

    The way it works is adding an option to the String() action, "-subst". If "-subst" is given, then environment variables in the other argument(s) are substituted. The variables use Unix shell syntax, e.g.:
    String(-subst, "login ${USER}"

    This feature will be included in x3270 4.2.

     
  • Sardonimous

    Sardonimous - 2021-11-15

    That's great!
    I thought I had the most current code, but I don't see this and my build is not recognizing "-subst" as anything special. Not a git pro, however. Was it committed?

     
  • Paul Mattes

    Paul Mattes - 2021-11-15

    Oops, yes, it was committed, but I hadn't pushed it to Sourceforge and Githib. It should be there now.

     
  • Sardonimous

    Sardonimous - 2021-11-15

    Thanks, work like a champ.

     

Log in to post a comment.