LET Sys_db_type ALLBASE
LET Sys_db_initialized 0

INPUT 'db_defaults'   { remains ASCII }
INPUT 'db_tab_def'   { remains ASCII }
LOAD_MACRO 'db_tab'     { ready for LOAD_MACRO }

{ Table initializations }
Tab_display_attributes
Tab_display_attributes_query
Tab_display_select_attributes_query
Tab_display_select_attributes_confirm
Tab_display_sort_attributes_query
Tab_display_files
Tab_display_elements
Tab_display_classes
Tab_display_history
Tab_insert_attributes
Tab_load_drawing
Tab_dbstore_cmd
Tab_remove_cmd
Tab_restore_cmd
Tab_mod_relations
Tab_mod_user
Tab_system_select

{ Database localization section for all DB macros.  This macro maps
  table values to appropriate macros.  Other macros call these macros
  to set proper column names.  }

DEFINE Sm_set_database_language

  { Localizable database table names }
  LET Dtab_query_results              'query_results'
  LET Dtab_classes                    'classes'
  LET Dtab_attributes                 'attributes'
  LET Dtab_attributes_query           'attributes_query'
  LET Dtab_select_attributes_confirm  'select_attributes_confirm'
  LET Dtab_select_attributes_query    'select_attributes_query'
  LET Dtab_sort_attributes_query      'sort_attributes_query'

  { Localizable display table titles }
  LET TITLE_ATTRIBUTES                "ATTRIBUTES"
  LET TITLE_AREAS                     "AREAS FOUND"
  LET TITLE_CLASSES                   "CLASSES FOUND"
  LET TITLE_FILES                     "FILES FOUND"
  LET TITLE_RELATIONS                 "RELATIONS FOUND"
  LET TITLE_STRUCTURE                 "STRUCTURE FOUND"
  LET TITLE_WHERE_USED                "WHERE_USED FOUND"
  LET TITLE_QUERY_RESULTS             "QUERY RESULTS"
  LET TITLE_FILES_TO_ELEMENTS         "FILES TO ELEMENTS"
  LET TITLE_ELEMENTS_TO_FILES         "ELEMENTS TO FILES"

  LET ATT_TITLE_CLASSES               "CLASSES"
  LET ATT_TITLE_FILES                 "FILES"

  { Localizable display table column names }
  LET COLUMN_C_ATTRIBUTE              "Attribute"
  LET COLUMN_C_CHILD_CLASS            "Child_Class"
  LET COLUMN_C_CLASS                  "Class"
  LET COLUMN_C_LENGTH                 "Length"
  LET COLUMN_C_PARENT_CLASS           "Parent_Class"
  LET COLUMN_C_PRECISION              "Precision"
  LET COLUMN_C_SCALE                  "Scale"
  LET COLUMN_C_TYPE                   "Type"

END_DEFINE
{ end of localization section }

LOAD_MACRO 'db_macro'   { ready for LOAD_MACRO }

LET Select_input_activ 0
LET Delete_occurred 0

{ ************************************************* }
{ Start of HP-DMS application initialization macros }

{ Title Block initialization }
LOAD_MACRO 'tb_macro'   { ready for LOAD_MACRO }
INPUT 'tb_setup'        { remains ASCII }

Tb_localizeable_strings
Tb_table_names_define
Tb_names_dtab_define
Tb_value_dtab_define
Tb_info_dtab_define
{ End Title Block initialization }

LET Dm_cnc_enabled    0
LET Dm_bom_enabled    0

{ ************************************************* }

DEFINE Cnc_input_file

	LOCAL Db_connect

	LET Db_connect Data_base_connected
	IF (Db_connect AND Dm_cnc_enabled)
	    INPUT 'cnc_setup'  { calls from here ready for LOAD_MACRO }
	END_IF

END_DEFINE

{ ************************************************* }

DEFINE Bom_input_file

	LOCAL Db_connect

	LET Db_connect Data_base_connected
	IF (Db_connect AND Dm_bom_enabled)
	    INPUT 'bom_setup'{ calls from here ready for LOAD_MACRO }
	END_IF

END_DEFINE

{ ************************************************* }

DEFINE Enable_dm_classification

  LOAD_MODULE 'CLASSIFICATION'
  LET Dm_cnc_enabled 1

  Cnc_input_file

END_DEFINE

{ ************************************************* }

DEFINE Enable_dm_bom

   LOAD_MODULE 'BOM'
   LET Dm_bom_enabled 1

   Bom_input_file

END_DEFINE

{ ************************************************* }

DEFINE Sm_bom_menu

   BEEP
   DISPLAY "*** BOM not enabled"

END_DEFINE

{ ************************************************* }

DEFINE Sm_cnc_menu_1

   BEEP
   DISPLAY "*** Classification not enabled"

END_DEFINE

{ ************************************************* }

DEFINE Sm_ap_connect

	Cnc_input_file

	Bom_input_file

	Tb_initialize

END_DEFINE

{ End HP-DMS application initialization macros }
{ ************************************************* }

{ ************************************************* }
{ Start HP-DMS menu initialization macros }

{ Calling Sm_data_management from another macro will 
  abort any subsequent READ  operations  in the same 
  macro  without  any  warnings. This happens because
  INPUT command on files is disallowed from a macro,
  and Sm_data_management does INPUT the required files.
  As soon as you put a call to Sm_data_management in
  your macros, the INPUT done by Sm_data_management
  becomes invalid. }

DEFINE Sm_data_management 
   LOCAL Db_connect

   LET   Db_connect   Data_base_connected   IF  (NOT   Db_connect)   LET
   Sys_db_initialized  0 CONNECT  Sys_db_type IF  (Sys_db_type = ORACLE)
   Sys_ora_sid END_IF Sys_server_node Sys_database END_IF

    {Initialiazation section - used to be in db_macro, necessary for
  					db_local_language}
   IF (NOT Sys_db_initialized)
    Sm_set_database_language
    Init_sel_attr_query_list
    Init_sort_attr_query_list
    Init_attr_query_list
    Init_sel_attr_list
    Init_attr_list
    Get_program_name
    Sm_dms_menu_type

    IF (Menu_fits)
	Dm_menu_layout
    END_IF
    Sm_data_management_query
    LET Sys_db_initialized 1

    QUERY_LIMIT Query_max_records
    Sm_ap_connect
   END_IF
  
   CURRENT_MENU 'Data_management_menu'

END_DEFINE

{ ************************************************* }
