Converts DFHMDF macro specifications into text_field
definitions for use with the TE3270 gem. The purpose is to eliminate the need for you to count the characters across and down a 3270 screen to determine the X and Y coordinates and the length of each field you wish to define for TE3270.
Given a BMS macro source file named macro-source
with the following contents:
QCKSET DFHMSD TYPE=MAP,STORAGE=AUTO,MODE=OUT,LANG=COBOL,TIOAPFX=YES
QCKMAP DFHMDI SIZE=(24,80),LINE=1,COLUMN=1,CTRL=ALARM
DFHMDF POS=(1,1),LENGTH=3,ATTRB=(ASKIP,BRT),INITIAL='QCK'
TITLE DFHMDF POS=(1,26),LENGTH=28,ATTRB=(ASKIP,NORM), X
INITIAL='Quick Customer Account Check'
HEAD DFHMDF POS=(3,1),LENGTH=8,ATTRB=(ASKIP,NORM),INITIAL='Account:'
ACCTNO DFHMDF POS=(3,13),LENGTH=7,ATTRB=(ASKIP,NORM)
DFHMDF POS=(4,1),LENGTH=5,ATTRB=(ASKIP,NORM),INITIAL='Name:'
SURNAME DFHMDF POS=(4,13),LENGTH=15,ATTRB=(ASKIP,NORM)
FNAME DFHMDF POS=(4,30),LENGTH=10,ATTRB=(ASKIP,NORM)
DFHMDF POS=(5,1),LENGTH=11,ATTRB=(ASKIP,NORM), X
INITIAL='Max charge:'
CHG DFHMDF POS=(5,13),ATTRB=(ASKIP,NORM),PICOUT='$,$$0.00'
MSG DFHMDF LENGTH=20,POS=(7,1),ATTRB=(ASKIP,NORM)
DFHMSD TYPE=FINAL
run dfhmdf
as a command-line utility:
dfhmdf macro-source > target-file
to produce the following output:
text_field(:x2y1, 1, 2, 3)
text_field(:title, 1, 27, 28)
text_field(:head, 3, 2, 8)
text_field(:x5y1, 4, 2, 5)
text_field(:surname, 4, 14, 15)
text_field(:fname, 4, 31, 10)
text_field(:x6y1, 5, 2, 11)
text_field(:chg, 5, 14, 8)
text_field(:msg, 7, 2, 20)
From the example you may surmise:
- It only pays attention to DFHMDF macros.
- It uses the downcased label value as the TE3270 field name, or a name like 'x14y12' for unlabeled DFHMDF macros.
- It adjusts the X axis offset to account for the attribute byte.
- When PICOUT is specified instead of LENGTH, it derives the length from the PICOUT value.
- It generates only
text_field
definitions, and not a complete TE3270 screen class.
So, if you have coded a TE3270 screen class like this:
class MainframeScreen
include TE3270
def login(username, password)
self.userid = username
self.password = password
end
end
emulator = TE3270.emulator_for :extra do |platform|
platform.session_file = 'sessionfile.edp'
end
my_screen = MainframeScreen.new(emulator)
my_screen.userid = 'the_id'
my_screen.password = 'the_password'
then you can paste in the generated text_field
definitions like this:
class MainframeScreen
include TE3270
text_field(:acctno, 4, 13, 7)
text_field(:surname, 5, 13, 15)
text_field(:fname, 5, 30, 10)
text_field(:chg, 6, 13, 8)
text_field(:msg, 8, 1, 20)
def login(username, password)
self.userid = username
self.password = password
end
end
emulator = TE3270.emulator_for :extra do |platform|
platform.session_file = 'sessionfile.edp'
end
my_screen = MainframeScreen.new(emulator)
my_screen.userid = 'the_id'
my_screen.password = 'the_password'
Add this line to your application's Gemfile:
gem 'dfhmdf'
And then execute:
$ bundle
or install it yourself as:
$ gem install dfhmdf
- Fork it ( https://github.com/[my-github-username]/dfhmdf/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request