Giter Site home page Giter Site logo

go3270's Introduction

go3270 Build Status Release License: MIT GoDoc

go3270 is a Golang interface to 3270 terminal emulator.

Requirements

  • go3270 require x3270 executables in your PATH

  • Go 1.11.x or greater

x3270 support versions

  • v3.3.14ga11

Install

$ go get github.com/msalcantara/go3270

Example

package main

import (
	"log"

	"github.com/msalcantara/go3270"
)

func main() {

	e := go3270.Emulator{
		Host: "0.0.0.0",
		Port: 992,
	}

	if err := e.Connect(); err != nil {
		log.Fatalf("error to create connection: %v\n", err)
	}

	if err := e.SetString("my_user"); err != nil {
		log.Fatalf("error to set user: %v\n", err)
	}

	if err := e.Press(go3270.Tab); err != nil {
		log.Fatalf("error to press tab: %v\n", err)
	}

	if err := e.SetString("my_password"); err != nil {
		log.Fatalf("error to set password: %v\n", err)
	}

	if err := e.Press(go3270.Enter); err != nil {
		log.Fatalf("error to press enter: %v\n", err)
	}

	v, err := e.GetValue(0, 1, 4)
	if err != nil {
		log.Fatalf("error to get value: %v", err)
	}
	log.Println(v)

	if err := e.Disconnect(); err != nil {
		log.Fatalf("error to disconnect: %v\n", err)
	}

}

License

go3270 is licensed under the MIT license.

go3270's People

Contributors

mattheusv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go3270's Issues

Problem when Input PF Key

Hi,
First thing is thanks for cool packages to utilize x3270, I'm using it a lot you know because work related

The problem is, it looks like we can't send F1-F12 key function because validaKeyboard() function always return false in case we send F1-F12 key even it's provided in constant variables causing all variables apart from Enter and Tab useless.

// These constants represent the keyboard keys
const (
	Enter = "Enter"
	Tab   = "Tab"
	F1    = "PF(1)"
	F2    = "PF(2)"
	F3    = "PF(3)"
	F4    = "PF(4)"
	F5    = "PF(5)"
	F6    = "PF(6)"
	F7    = "PF(7)"
	F8    = "PF(8)"
	F9    = "PF(9)"
	F10   = "PF(10)"
	F11   = "PF(11)"
	F12   = "PF(12)"
)

......

//Press press a keyboard key
func (e *Emulator) Press(key string) error {
	if !e.validaKeyboard(key) {
		return fmt.Errorf("invalid key %s", key)
	}
	return e.execCommand(key)
}

//validaKeyboard valid if key passed by parameter if a key valid
func (e *Emulator) validaKeyboard(key string) bool {
	switch key {
	case Tab:
		return true
	case Enter:
		return true
	default:
		return false
	}
}

Should be checked whether it's key command function or not and send command below for example :
x3270if -t e.ScriptPort PF(1)

Maybe adding more function for PF key or just checking input in press() will solve the problem.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.