Proc Examples

The following Procs are provided for your convenience. NEC Software Solutions does not officially support them.

Note

The online documentation includes all the updates till fix version V15.1.0.0410In the following examples, \ is a subvalue mark (CTRL+\) and ] is a value mark (CTRL+]).

Date Conversion

This routine prompts for an input, or uses a value passed by another Proc or DataBasic program, and converts a date from external to internal format, or vice-versa.

    DATECONV
001 PQN
002 C Date Conversion Routine (in or out)
003 C name of programmer*date
004   IF # %2 GO F
005   GOSUB 1
006   X
007 M\T "INPUT DATE",+\IBP:%2\IF # %2 X
008   GOSUB 1
009   GO B
010 1 IF %2 = (ON) ] (2N/2N/2N) ] (2N-2N-2N)
    T U,(21),%2:D2/:]T U,(21),%2;D2/;] T U, (21),%2;D2-;\RSUB
011   T "Format must be mm/dd/yr, mm-dd-yr, or
      numeric..."\T""
012   RSUB

Creating a Control File

This Proc can be used to create and set-up a file for inventory control. Each file controls a particular article, in this case the inventory and distribution of a publication.

A 'Master' file contains a standard dictionary and control item that is copied to each control file. This Proc creates the inventory file, copies the dictionary from the 'Master' file and copies the control item from the 'Master' file.

    NEWFILE
001 PQN
002 C* Create a new publication control file
003 C* Programmer's Name - Date
004    IF %2 G 5
005    T "Enter NUMBER of Publication ",+
006    IP:%2
007    IF # %2 X
008 5  HCREATE-FILE
009    MV #2 "("*%2
010    H 1,1 11,1)
011    PH
012    HCOPY DICT MASTER *
013    STON
014    H(DICT
015    MV #2 %2*")<"
016    PH
017    HCOPY MASTER CONTROL.ITEM
018    STON
019    MV #1 "("*%2*")"
020    H CONTROL<
021    PH
022    T "CREATED '",%2,"' FILE, COPIED DICT AND
       CONTROL FROM MASTER FILE."

DataBasic Programming Aid

This Proc provides a menu and selections for Editing, Compiling, Running, and Debugging DataBasic programs.

Assuming that the program name is 'BSC' and that it resides in a file called 'PROCFILE', create the following MD entry to invoke the Proc:

MD Entry

    BSC
001 PQN
002 (PROCFILE)

Program

    BSC
001 PQN
002 C** DataBasic Programming Aid
003 C** Programmer's Name - Date
004   IF %2 G 2
005 1  OFile Name +
006   IP=%2\IF # %2 X
007 2  IF %3 G 4
008   OItem Name +
009   IP=%3
010 4  T C
011   F-O 1 %2
012   T "FILE '",%2,"' Doesn't exist..."\G 1
013 5  F-R 1 %3
014   GOSUB 199
015   T (15,0),"DataBasic DEVELOPMENTAL ASSISTANCE
       PROGRAM"
016   T (15,1),*-43
017   T (60,2),"FILE:  ",%2
018   T (60,3),"ITEM:  ",%3
019   T (0,3),"SELECTIONS:"
020   T (5,4),"E  - EDIT"
021   T (5,5),"C  - COMPILE"
022   T (5,6),"CM - COMPILE WITH SYMBOL TABLE"
023   T (5,7),"CL - COMPILE WITH LIST (L)"
024   T (5,8),"R  - 'RUN' BASIC PROGRAM"
025   T (5,9),"G  - EXECUTE CATALOGUED PROGRAM"
026   T (5,10),"L  - CATALOG PROGRAM"
027   T (5,11),"P  - COPY TO PRINTER"
028   T (5,12),"DO - DELETE OBJECT CODE"
029   T (5,13),"DT - DELETE SYMBOL TABLE"
030   T (5,14),"DE - DELETE SOURCE ITEM"
031   T (5,15),"DC - DELETE CATALOG ENTRY"
032   T (0,17),"CHOICE...",+
033   IP:%4\IF # %4 X
034   IF %4 = E]C]CM]CL]R]G G 10]15]25]30]35]40
035   IF %4 = L]P]DO]DT]DE]DC G 45]50]55]65]70]75
036   G 4
037 10  HED
038   MV #2 %2,%3
039   STON
040   HTB 06,09,12,15,18,21,40,68<
041   HP L22<
042   HP<
043   P
044   G 4
045 15  HBASIC
046 20  MV #2 %2,%3
047   P
048   G 99
049 25  HBASIC
050   MV #4 "(M)"
051   G 20
052 30  HBASIC
053   MV #4 "(L)"
054   G 20
055 35  HRUN
056   G 20
057 40  MV #1 %3
058   P
059   G 99
060 45  HCATALOG
061   G 20
062 50  HCOPY
063   MV #2 %2,%3,"(P)"
064   P
065   G 4
066 55  MV &1.0 "$"*%3
067 60  F-D 1
068   T "'",&1.0,"' DELETED"
069   G 99
070 65  MV &1.0 "*"*%3
071   G 60
072 70  MV &1.0 %3
073   G 60
074 75  HDELETE-CATALOG
075   MV #2 %3
076   P
077 99  IP>%4
078   G 4
079 199 T (66,4),I3,I66,"NEW ITEM",I3,I32
080   RSUB

The 'G 99' command used throughout the program is to provide a prompt for input to allow you to read system messages, compiler messages, etc.

The program accepts the file and item names passed when the program is invoked or else it prompts for them.

If you are going to be working on a DataBasic program for a long time, or over again many times, here is a Proc for your MD to make things easier. By creating this item in your MD and assigning it a short name, you will only have to type that short name at TCL rather than be prompted for file and item names. Again assuming that the Proc name is 'BSC' and that it's in the 'PROCFILE' file, and that the DataBasic program is named 'PROGRAM' and is in the 'BP' file:

    SHORT
001 PQN
002 RI2
003 IHBP PROGRAM
004 (PROCFILE BSC)