BRICKHOUSE

Integrating mfsort with Net Express

Summary: Since mfsort is a command line utility you have to write some scripts and define entries under tools in order to run sorts from inside of Net Express. The method described on this page is used in an actual development environment and has been run using windows 98, NT, and 2000. It should be fairly easy to adapt to other Net Express configurations. The screen shots are taken from a windows 2000 machine. When things differ between flavors it will be noted in the text.

Editing sorts in Net Express

In our shop all sorts have the file extension .srt in order to distinguish them from other types of source files. We have created a file type for sorts by using Folder Options in Explorer or the Control Panel.

Folder Options, File Types

Click New and add the extension SRT.
Create New Extension

Next click Advanced, specify that a file with extension .srt is a Mfsort File. The icon was selected from the file mficns10.dll which can be found in the Net Express Base/BIN directory.
Edit File Type

Add the open action by clicking New. The application to use is MFNETX.EXE located in the Net Express Base/BIN directory. Tick Use DDE and enter the open DDE message.
Edit Action Open

Add the view action by clicking New. The application to use is NotepadEx (see Replacing notepad below). For this action DDE is not used.
Edit Action View

By doing this, in order to edit a sort source file, you only have to double-click it. Since Net Express is set up to handle these files you should add an edit profile for sorts. To do this simply go to Edit Options in Net Express and add the following profile:
NE Edit Options

The view action makes it possible to quickly view, and if necessary, edit a sort file without having to start Net Express. By right-clicking a sort file and choosing view the sort is opened in NotepadEx instead of Net Express.

A mfsort wrapper script

This version should run under Windows 9x/NT/2000.

01  @echo off
02  rem mfsort.bat
03  rem
04  rem Shell wrapper to run mfsort files from the NE Tools menu.
05  rem Modeled on the NE cmd-prompt to get a runnable environment.
06  rem
07  rem
08  rem Robert de Mander, Robdem Soft AB
09  rem
10
11  call createnv.bat
12
13  if NOT x%TMP% == x goto :endif0
14    set TMP=%TEMP%
15  :endif0
16
17  set dd_SYSOUT=%TMP%\mfsort.log
18
19  if NOT x%COBDIR% == x goto :endif1
20    echo Error: COBDIR not set, this will not work > %dd_SYSOUT%
21    goto :stoprun
22  :endif1
23
24  if NOT x%1 == x goto :endif2
25    echo Error: No sort name specified on command line > %dd_SYSOUT%
26    goto :stoprun
27  :endif2
28
29  if NOT exist h:\neprojects\%1 goto :else3
30    set SORTFILE=h:\neprojects\%1
31    goto :endif3
32  :else3
33    if NOT exist e:\develsort\%1 goto :else4
34      set SORTFILE=e:\develsort\%1
35      goto :endif3
36    :else4
37      echo Warning: Sort not found in source directories > %dd_SYSOUT%
38      set SORTFILE=%1
39  :endif3
40
41  E:
42  cd \develdata
43
44  mfsort take %SORTFILE%
45
46  if errorlevel 1 goto :errexit
47    echo Info: mfsort exited 0 >> %dd_SYSOUT%
48    goto :stoprun
49  :errexit
50    echo Error: mfsort returned code %errorlevel%  >> %dd_SYSOUT%
51    goto :stoprun
52  :errend
53
54  :stoprun
55  start N:\notepadx\notepad %dd_SYSOUT%
56
57  exit

Script comments

The script should be started in the Net Express ./Base/BIN directory since it needs to find the createnv.bat script. Another possibility is adding that directory to your PATH or change line 11 and specify the complete pathname to the script instead of calling it by name.

Replacing notepad

If you're in a mixed development environment and accessing files on both windows and one or more unix hosts you need to replace Notepad with an editor that can handle files with both lf and cr-lf line terminators.

The one we use in this environment is NotepadEx which has the look-and-feel of vanilla Notepad but none of the limitations. Another plus is the fact that it requires no installation it's just one .exe file which makes it load fast. We use it to look at log files, data files, and as a quick viewer for sort source files. NotepadEx is freeware so the price is hard to beat.

Adding mfsort as a tool

When setting up mfsort as a tool in Net Express you can run a sort by adding it to your project, selecting it by clicking, and then using Tools, Run mfsort to run it. To add a tool enter Customize and the Tools tab, click New Tool...

NE Customize Tools

If you are running windows 9x you have to make sure that the environment size is big enough to create your Net Express Command Prompt. Change the Command: entry above to read:

   C:\windows\command.com /E:8192 /K N:\runmfsort\mfsort.bat

This should be enough in most cases, if not increase the value after the /E switch.

Summary

Being able to add, edit, and run mfsort files from inside Net Express has simplified and speeded our development cycle when working with stand-alone sorts. The only problem we have found so far is when creating an output file as line sequential.

If we run the sort using Server Express we get unix line terminators and if we run it in Net Express we get windows line terminators. This can cause problems especially if you're using Samba to create files on your unix host.

One way around this is to make the file sequential and add a lf using outrec. Your sort gets a bit more complicated but you're guaranteed to always have the same line terminators regardless of from where you run the sort.