Skip to content

Moving from go3270 to go-ibmterm

go-ibmterm is the next version of D-Modem/go3270. It serves 3270 and 5250 terminals with one screen model, and its API is different. This page tells how to change a program that uses go3270.

Packages

Old New
github.com/D-Modem/go3270 (package go3270) github.com/D-Modem/go-ibmterm (package ibmterm): the screen model
github.com/D-Modem/go-ibmterm/tn3270: the 3270 data stream
github.com/D-Modem/go-ibmterm/tn5250: the 5250 data stream

Screen, Field, Color, Highlight, Response, ScreenOpts, ShowScreenOpts, HandleScreen, RunTransactions, Rules and the code pages are in ibmterm. The telnet negotiation, the query replies, the graphics and IND$FILE are in tn3270.

Changes

  1. Change go3270.NegotiateTelnet(conn) to tn3270.NegotiateTelnet(conn). It returns a tn3270.DevInfo, which is an ibmterm.Terminal.
  2. Change ScreenOpts.AltScreen to ScreenOpts.Terminal. The field is necessary. ShowScreenOpts returns ibmterm.ErrNoTerminal if it is nil. The library writes to the screen of Terminal.Size(), or to the default screen when ScreenOpts.DefaultScreen is true (see 3270 screen sizes).
  3. You do not have to set ScreenOpts.Codepage. The library uses the code page of the Terminal. Set it only to use a different code page.
  4. Change HandleScreen and HandleScreenAlt to the new HandleScreen. Its last argument is the Terminal. The optional code page argument is gone.
  5. Change Response.AID to Response.Key, and the type AID to Key. Change the AID constants:

    Old New
    AIDEnter KeyEnter
    AIDPF1 to AIDPF24 KeyF1 to KeyF24
    AIDPA1 to AIDPA3 KeyPA1 to KeyPA3
    AIDClear KeyClear
    AIDNone KeyNone
    AIDtoString(aid) key.String() (for example "F3", not "PF3")
  6. Change DevInfo.AltDimensions() to Terminal.Size().

  7. A Tx function gets an ibmterm.Terminal, not a DevInfo. Use a type assertion to tn3270.DevInfo for the features of a 3270 only.
  8. ShowScreen() and ShowScreenNoResponse() are gone. Use ShowScreenOpts().

New

  • Terminal.Kind() tells if the terminal is a 3270 or a 5250.
  • Terminal.Color() tells if the terminal shows colors.
  • Key.HasData() tells if the client sends the fields with a key.
  • KeyPageUp, KeyPageDown, KeyHelp, KeyPrint, KeyAttn and KeySysReq come from a 5250. A 3270 does not send them.
  • ibmterm.CodepageByID() returns a code page by its IBM number.

Refer to TN5250 for the 5250 data stream.