home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / Cobol32 / PowerOCX / bsrtocx.z / sample1.frm < prev    next >
Text File  |  1997-05-14  |  14KB  |  451 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "PowerBSORT OCX Sample"
  5.    ClientHeight    =   3795
  6.    ClientLeft      =   1695
  7.    ClientTop       =   1500
  8.    ClientWidth     =   5895
  9.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   12
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   4215
  19.    Icon            =   "sample1.frx":0000
  20.    Left            =   1635
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   4188.491
  25.    ScaleMode       =   0  'User
  26.    ScaleWidth      =   6007.124
  27.    Top             =   1140
  28.    Width           =   6015
  29.    Begin VB.CommandButton Command1 
  30.       Caption         =   "Sort"
  31.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  32.          Name            =   "MS Sans Serif"
  33.          Size            =   8.25
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   360
  41.       Left            =   2353
  42.       TabIndex        =   12
  43.       Top             =   3363
  44.       Width           =   1188
  45.    End
  46.    Begin VB.CommandButton Command2 
  47.       Caption         =   "Exit"
  48.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  49.          Name            =   "MS Sans Serif"
  50.          Size            =   8.25
  51.          Charset         =   0
  52.          Weight          =   400
  53.          Underline       =   0   'False
  54.          Italic          =   0   'False
  55.          Strikethrough   =   0   'False
  56.       EndProperty
  57.       Height          =   447
  58.       Left            =   4823
  59.       TabIndex        =   6
  60.       Top             =   108
  61.       Width           =   956
  62.    End
  63.    Begin VB.Frame Frame5 
  64.       Caption         =   "Return code"
  65.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  66.          Name            =   "MS Sans Serif"
  67.          Size            =   8.25
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       Height          =   552
  75.       Left            =   2340
  76.       TabIndex        =   1
  77.       Top             =   0
  78.       Width           =   2244
  79.       Begin VB.Label la_Detail 
  80.          Caption         =   "Detail:"
  81.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  82.             Name            =   "MS Sans Serif"
  83.             Size            =   8.25
  84.             Charset         =   0
  85.             Weight          =   400
  86.             Underline       =   0   'False
  87.             Italic          =   0   'False
  88.             Strikethrough   =   0   'False
  89.          EndProperty
  90.          Height          =   252
  91.          Left            =   1080
  92.          TabIndex        =   4
  93.          Top             =   240
  94.          Width           =   612
  95.       End
  96.       Begin VB.Label la_Error 
  97.          Caption         =   "Error:"
  98.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  99.             Name            =   "MS Sans Serif"
  100.             Size            =   8.25
  101.             Charset         =   0
  102.             Weight          =   400
  103.             Underline       =   0   'False
  104.             Italic          =   0   'False
  105.             Strikethrough   =   0   'False
  106.          EndProperty
  107.          Height          =   255
  108.          Left            =   120
  109.          TabIndex        =   2
  110.          Top             =   240
  111.          Width           =   495
  112.       End
  113.       Begin VB.Label la_DetailVal 
  114.          Caption         =   "Label4"
  115.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  116.             Name            =   "MS Sans Serif"
  117.             Size            =   8.25
  118.             Charset         =   0
  119.             Weight          =   400
  120.             Underline       =   0   'False
  121.             Italic          =   0   'False
  122.             Strikethrough   =   0   'False
  123.          EndProperty
  124.          Height          =   252
  125.          Left            =   1680
  126.          TabIndex        =   5
  127.          Top             =   240
  128.          Width           =   432
  129.       End
  130.       Begin VB.Label la_ErrorVal 
  131.          Caption         =   "Label4"
  132.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  133.             Name            =   "MS Sans Serif"
  134.             Size            =   8.25
  135.             Charset         =   0
  136.             Weight          =   400
  137.             Underline       =   0   'False
  138.             Italic          =   0   'False
  139.             Strikethrough   =   0   'False
  140.          EndProperty
  141.          Height          =   255
  142.          Left            =   600
  143.          TabIndex        =   3
  144.          Top             =   240
  145.          Width           =   495
  146.       End
  147.    End
  148.    Begin VB.Frame Frame1 
  149.       Caption         =   "Input Data"
  150.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  151.          Name            =   "MS Sans Serif"
  152.          Size            =   8.25
  153.          Charset         =   0
  154.          Weight          =   400
  155.          Underline       =   0   'False
  156.          Italic          =   0   'False
  157.          Strikethrough   =   0   'False
  158.       EndProperty
  159.       Height          =   2291
  160.       Left            =   120
  161.       TabIndex        =   8
  162.       Top             =   960
  163.       Width           =   2603
  164.       Begin VB.ListBox List1 
  165.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  166.             Name            =   "Fixedsys"
  167.             Size            =   9
  168.             Charset         =   0
  169.             Weight          =   400
  170.             Underline       =   0   'False
  171.             Italic          =   0   'False
  172.             Strikethrough   =   0   'False
  173.          EndProperty
  174.          Height          =   1860
  175.          Left            =   120
  176.          TabIndex        =   9
  177.          Top             =   240
  178.          Width           =   2415
  179.       End
  180.    End
  181.    Begin VB.Frame Frame2 
  182.       Caption         =   "Output Data"
  183.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  184.          Name            =   "MS Sans Serif"
  185.          Size            =   8.25
  186.          Charset         =   0
  187.          Weight          =   400
  188.          Underline       =   0   'False
  189.          Italic          =   0   'False
  190.          Strikethrough   =   0   'False
  191.       EndProperty
  192.       Height          =   2291
  193.       Left            =   3180
  194.       TabIndex        =   14
  195.       Top             =   960
  196.       Width           =   2603
  197.       Begin VB.ListBox List2 
  198.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  199.             Name            =   "Fixedsys"
  200.             Size            =   9
  201.             Charset         =   0
  202.             Weight          =   400
  203.             Underline       =   0   'False
  204.             Italic          =   0   'False
  205.             Strikethrough   =   0   'False
  206.          EndProperty
  207.          Height          =   1860
  208.          Left            =   120
  209.          TabIndex        =   15
  210.          Top             =   240
  211.          Width           =   2415
  212.       End
  213.    End
  214.    Begin VB.CommandButton Command3 
  215.       Caption         =   "View"
  216.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  217.          Name            =   "MS Sans Serif"
  218.          Size            =   8.25
  219.          Charset         =   0
  220.          Weight          =   400
  221.          Underline       =   0   'False
  222.          Italic          =   0   'False
  223.          Strikethrough   =   0   'False
  224.       EndProperty
  225.       Height          =   360
  226.       Left            =   780
  227.       TabIndex        =   10
  228.       Top             =   3360
  229.       Width           =   1188
  230.    End
  231.    Begin VB.TextBox InputFileText 
  232.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  233.          Name            =   "MS Sans Serif"
  234.          Size            =   8.25
  235.          Charset         =   0
  236.          Weight          =   400
  237.          Underline       =   0   'False
  238.          Italic          =   0   'False
  239.          Strikethrough   =   0   'False
  240.       EndProperty
  241.       Height          =   288
  242.       HelpContextID   =   1340
  243.       Left            =   118
  244.       TabIndex        =   7
  245.       Text            =   "Text1"
  246.       Top             =   651
  247.       Width           =   2603
  248.    End
  249.    Begin VB.TextBox OutputFileText 
  250.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  251.          Name            =   "MS Sans Serif"
  252.          Size            =   8.25
  253.          Charset         =   0
  254.          Weight          =   400
  255.          Underline       =   0   'False
  256.          Italic          =   0   'False
  257.          Strikethrough   =   0   'False
  258.       EndProperty
  259.       Height          =   288
  260.       HelpContextID   =   1390
  261.       Left            =   3176
  262.       TabIndex        =   13
  263.       Text            =   "Text1"
  264.       Top             =   651
  265.       Width           =   2603
  266.    End
  267.    Begin VB.CommandButton Command4 
  268.       Caption         =   "View"
  269.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  270.          Name            =   "MS Sans Serif"
  271.          Size            =   8.25
  272.          Charset         =   0
  273.          Weight          =   400
  274.          Underline       =   0   'False
  275.          Italic          =   0   'False
  276.          Strikethrough   =   0   'False
  277.       EndProperty
  278.       Height          =   360
  279.       Left            =   4000
  280.       TabIndex        =   16
  281.       Top             =   3363
  282.       Width           =   1188
  283.    End
  284.    Begin PowerBSORT_Lib.PowerBSORT PowerBSORT1 
  285.       Left            =   120
  286.       Top             =   3360
  287.       _Version        =   65536
  288.       _ExtentX        =   741
  289.       _ExtentY        =   741
  290.       _StockProps     =   0
  291.    End
  292.    Begin VB.Label Label1 
  293.       Caption         =   "Sample"
  294.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  295.          Name            =   "Arial"
  296.          Size            =   24
  297.          Charset         =   0
  298.          Weight          =   700
  299.          Underline       =   0   'False
  300.          Italic          =   -1  'True
  301.          Strikethrough   =   0   'False
  302.       EndProperty
  303.       ForeColor       =   &H00FF0000&
  304.       Height          =   624
  305.       Left            =   240
  306.       TabIndex        =   0
  307.       Top             =   0
  308.       Width           =   1896
  309.    End
  310.    Begin VB.Label Label2 
  311.       AutoSize        =   -1  'True
  312.       Caption         =   "->"
  313.       Height          =   300
  314.       Left            =   2820
  315.       TabIndex        =   11
  316.       Top             =   1980
  317.       Width           =   228
  318.    End
  319. End
  320. Attribute VB_Name = "Form1"
  321. Attribute VB_Creatable = False
  322. Attribute VB_Exposed = False
  323.  
  324. Option Explicit
  325. Const col_BackNormal = &HFFFFFF
  326. Const col_TextNormal = &H0
  327. Const col_BackOK = &HFF0000
  328. Const col_TextOK = &HFFFFFF
  329. Const col_BackErr = &HFF
  330. Const col_TextErr = &HFFFFFF
  331. Private Sub AfterAction()
  332.   Dim ErrCode, ErrDetail As Long
  333.   Dim col_Back, col_Text As Long
  334.   
  335.   ErrCode = PowerBSORT1.ErrorCode
  336.   ErrDetail = PowerBSORT1.ErrorDetail
  337.   la_ErrorVal.Caption = CStr(ErrCode)
  338.   la_DetailVal.Caption = CStr(ErrDetail)
  339.   If ErrCode = 0 Then
  340.     col_Back = col_BackOK
  341.     col_Text = col_TextOK
  342.   Else
  343.     col_Back = col_BackErr
  344.     col_Text = col_TextErr
  345.   End If
  346.   la_Error.ForeColor = col_Text
  347.   la_Error.BackColor = col_Back
  348.   la_ErrorVal.ForeColor = col_Text
  349.   la_ErrorVal.BackColor = col_Back
  350.   la_Detail.ForeColor = col_Text
  351.   la_Detail.BackColor = col_Back
  352.   la_DetailVal.ForeColor = col_Text
  353.   la_DetailVal.BackColor = col_Back
  354. End Sub
  355. Private Sub BeforeAction()
  356.   la_Error.ForeColor = col_TextNormal
  357.   la_Error.BackColor = col_BackNormal
  358.   la_ErrorVal.ForeColor = col_TextNormal
  359.   la_ErrorVal.BackColor = col_BackNormal
  360.   la_Detail.ForeColor = col_TextNormal
  361.   la_Detail.BackColor = col_BackNormal
  362.   la_DetailVal.ForeColor = col_TextNormal
  363.   la_DetailVal.BackColor = col_BackNormal
  364. End Sub
  365.  
  366. Private Sub Command1_Click()
  367.   BeforeAction
  368.   ' --- bigin ---
  369.   PowerBSORT1.InputFiles = InputFileText.Text
  370.   PowerBSORT1.InputFileType = 0
  371.   PowerBSORT1.OutputFile = OutputFileText.Text
  372.   PowerBSORT1.OutputFileType = 0
  373.   PowerBSORT1.MaxRecordLength = 100
  374.   PowerBSORT1.DisposalNumber = 0  ' Sort
  375.   PowerBSORT1.Action
  376.   ' --- end ---
  377.   AfterAction
  378.   If PowerBSORT1.ErrorCode = 0 Then
  379.     Command4.Enabled = True
  380.   End If
  381. End Sub
  382.  
  383. Private Sub Command2_Click()
  384.   Unload Me
  385. End Sub
  386.  
  387. Private Sub InFileView()
  388.   Dim fileNam, lin As String
  389.   Dim fileNum, lineCount As Long
  390.   
  391.   fileNam = InputFileText.Text
  392.   fileNum = FreeFile
  393.   On Error GoTo IopenError
  394.   Open fileNam For Input As #fileNum
  395.   List1.Clear
  396.   lineCount = 0
  397.   Do Until EOF(fileNum)
  398.     Line Input #fileNum, lin$
  399.     lineCount = lineCount + 1
  400.     If lineCount > 100 Then Exit Do
  401.     List1.AddItem lin$
  402.   Loop
  403.   Close #fileNum
  404.   Exit Sub
  405. IopenError:
  406.   Exit Sub
  407. End Sub
  408. Private Sub OutFileView()
  409.   Dim fileNam, lin As String
  410.   Dim fileNum, lineCount As Long
  411.   
  412.   fileNam = OutputFileText.Text
  413.   fileNum = FreeFile
  414.   On Error GoTo OopenError
  415.   Open fileNam For Input As #fileNum
  416.   List2.Clear
  417.   lineCount = 0
  418.   Do Until EOF(fileNum)
  419.     Line Input #fileNum, lin$
  420.     lineCount = lineCount + 1
  421.     If lineCount > 100 Then Exit Do
  422.     List2.AddItem lin$
  423.   Loop
  424.   Close #fileNum
  425.   Exit Sub
  426. OopenError:
  427.   Exit Sub
  428. End Sub
  429.  
  430. Private Sub Command3_Click()
  431.   InFileView
  432. End Sub
  433.  
  434. Private Sub Command4_Click()
  435.   OutFileView
  436. End Sub
  437.  
  438. Private Sub Form_Load()
  439.   App.HelpFile = "..\program\psocx.hlp"
  440.   InputFileText.Text = "data\sortin.txt"
  441.   OutputFileText.Text = "data\sortout.txt"
  442.   la_ErrorVal.Caption = ""
  443.   la_DetailVal.Caption = ""
  444. End Sub
  445.  
  446. Private Sub Form_Unload(Cancel As Integer)
  447.   Unload Me
  448. End Sub
  449.  
  450.  
  451.