Dbgl Examples
Basic operations
! Defining the environment environment demo ! Selecting database using database demo.tek/tek alias db1 ! Starting of the definition group grp1 define grp1 !Checking the end of file if no_more_data(db1) then stop 'End of database reading'. ! Selecting the Header record if current_record(db1:header) then ! Printing on the screen each site code output! = db1:header:site. always ! Reading of next line read db1. end of grp1 definition
! Local parameters environment krja ! Selecting database using database demo.tek/tek alias db1 ! Generating a new database group definition generate demob.tek/tek alias dbout ! Checking end of database if no_more_data(db1) then stop 'End of database generation'. ! copying and explicitly saving the header record into the new database if current_record(db1:header) then dbout:header = db1:header ; save dbout:header. ! copying the geotec (sample) information only for structures of type B if current_record(db1:geotec) and db1:geotec:type eqs "B" then dbout:geotec=db1:geotec. if current_record(db1:geotec) and db1:geotec:type eqs "B" then ! Explicity saving the information save dbout:geotec. always ! Getting a new record read db1. end of dbout generation
Mixing two fields into one new field
!Maptek Chile Ltda. !Script to mix a numerical field and a character field< !Date: December- 1996 !Author : Eric Gonzalez !Description: !Este script transforma un campo numerico en caracter y lo concatena !con otro campo de tipo caracter. El resultado se almacena en un campo !del mismo tipo llamado hb (caracter). ! !Para la transformacion crea una base de datos temporal llamada !esctmp.fin con el campo calculado. ! !Para ejecutar: ! ! dbgl <el nombre de este script> ! !Parametros locales y base de datos environment bhp using database esc.fin/fin alias db1 !Definicion de un campo como caracter para hacer la conversion define init always nuevo_campo = " " ; stop " Fin de la etapa inicial" . end of init definition ! Generacion de la nueva base de datos generate esctmp.fin/fin alias db3 if no_more_data(db1) then stop " Adicion terminada" . ! Copiado de los registros que no se modificaran if current_record(db1:collar) then db3:collar = db1:collar ; save db3:collar . if current_record(db1:survey) then db3:survey = db1:survey ; save db3:survey . if current_record(db1:geocod) then db3:geocod = db1:geocod ; save db3:geocod . if current_record(db1:assay) then db3:assay = db1:assay ; save db3:assay . if current_record(db1:dhfaul) then db3:dhfaul = db1:dhfaul ; save db3:dhfaul . if current_record(db1:wind) then db3:wind = db1:wind ; save db3:wind . if current_record(db1:geotec) then db3:geotec = db1:geotec ; save db3:geotec . ! Calculo del campo nuevo. if current_record(db1:geotin) then db3:geotin = db1:geotin ; nuevo_campo = db1:geotin:surcon ; db3:geotin:hb = pack(ljust(rockst)&ljust(nuevo_campo)); save db3:geotin . always read db1 . end of db3 generation
Addition of samples field to reach the survey bottom depth in a drill hole database
! Script for tacking on an extra assay record if the down-hole ! surveys exceed the assay intervals. The added assay record ! consists of the last "TO" of the previous assay record and ! the depth of the last survey record. ! Note the line "newdb:assay:au = -9.0 ;" you will want to modify ! this so that garbage is not put into other assay fields, for example,, be ! sure to account for all other assay fields in the assay record. ! Also adds records to end of the surveying for Lithology, Alterisation, ! Mineralisation, and Structure. ! ! If no assays, lithology, etc exist for the hole, then one dummay record is ! added for the entire hole. ! ! Bob Nutsch, Denver Office ! Mike Husbands, Santiago Office ! August 1996 environment cmei assign output! to list.out ! copy from this database using database indi.ddh/ddh alias olddb define init always survdepth = 0 ; asyto = 0 ; altto = 0 ; lithto = 0 ; minto = 0 ; estrto = 0 ; TRUE = 1 ; FALSE = 0 ; no_assays = FALSE ; no_alt = FALSE ; no_lith = FALSE ; no_min = FALSE; no_estr = FALSE ; stop "End of init" . end of init definition ! copy to this database generate indifixed.ddh/ddh alias newdb if no_more_data(olddb) then stop "End of adding assay records" . if ( current_record(olddb:collar) and no_assays eq TRUE ) or (finished_record(olddb:assays) and survdepth gt asyto ) then output! = "Hole ID: " & currholeid & " New assay To depth = " & format(survdepth,"F10.3") ; newdb:assays:from = asyto ; newdb:assays:to = survdepth ; newdb:assays:largo = survdepth - asyto ; newdb:assays:sample = 9999 ; newdb:assays:veta = ' ' ; newdb:assays:nsr = 9999 ; newdb:assays:au = -999.0 ; newdb:assays:ag = -999.0 ; newdb:assays:cu = -999.0 ; save newdb:assays ; asyto = 0 ; no_assays = FALSE . if ( current_record(olddb:collar) and no_lith ) or ( finished_record(olddb:lith) and survdepth gt lithto ) then output! = "Hole ID: " & currholeid & " New lith To depth = " & format(survdepth,"F10.3") ; newdb:lith:from = lithto ; newdb:lith:to = survdepth ; newdb:lith:lith = "9999" ; save newdb:lith ; lithto = 0 ; no_lith = FALSE . if ( current_record(olddb:collar) and no_alt) or (finished_record(olddb:alt) and survdepth gt altto ) then output! = "Hole ID: " & currholeid & " New alt To depth = " & format(survdepth,"F10.3") ; newdb:alt:from = altto ; newdb:alt:to = survdepth ; newdb:alt:alt1 = "9999" ; newdb:alt:alt2 = "9999" ; save newdb:alt ; altto = 0 ; no_alt = FALSE . if ( current_record(olddb:collar) and no_min ) or (finished_record(olddb:min) and survdepth gt minto ) then output! = "Hole ID: " & currholeid & " New min To depth = " & format(survdepth,"F10.3") ; newdb:min:from = minto ; newdb:min:to = survdepth ; newdb:min:min1 = "9999" ; newdb:min:min2 = "9999" ; save newdb:min ; minto = 0 ; no_min = FALSE . if ( current_record(olddb:collar) and no_estr ) or (finished_record(olddb:estr) and survdepth gt estrto ) then output! = "Hole ID: " & currholeid & " New estr To depth = " & format(survdepth,"F10.3") ; newdb:estr:from = estrto ; newdb:estr:to = survdepth ; newdb:estr:estr = "9999-999.0" ; save newdb:estr ; estrto = 0 ; no_estr = FALSE . if current_record(olddb:collar) then ! no_assays = TRUE ; no_lith = TRUE ; no_alt = TRUE ; no_min = TRUE ; no_estr = TRUE ; ! ! Write new collar record ! newdb:collar = olddb:collar ; currholeid = olddb:collar:holeid ; save newdb:collar . ! endif (current_record(olddb:collar) if current_record(olddb:survey) then newdb:survey = olddb:survey ; survdepth = olddb:survey:to ; save newdb:survey . if current_record(olddb:assays) then newdb:assays = olddb:assays ; asyto = olddb:assays:to ; save newdb:assays . if current_record(olddb:lith) then newdb:lith = olddb:lith ; lithto = olddb:lith:to ; save newdb:lith . if current_record(olddb:alt) then newdb:alt = olddb:alt ; altto = olddb:alt:to ; save newdb:alt . if current_record(olddb:min) then newdb:min = olddb:min ; minto = olddb:min:to ; save newdb:min . if current_record(olddb:estr) then newdb:estr = olddb:estr ; estrto = olddb:estr:to ; save newdb:estr . always read olddb . end of newdb generation
Projecting of a geotechnical database to a nominated level
!Maptek Chile Ltda. !Script to project geotechnical databases !Date: December- 1996 !Author : Eric Gonzalez !Description: ! This Script projects a geotec database to a nominated level. ! The projection is in the form of a new "tek" database with ! The same structure and values than the original database ! excepting for coordinates of structures. ! Also this script creates an ASCII file with points to load ! as lines using Envisage's ASCII import procedure. This ASCII ! may be loaded as lines to generate an extension of each ! structure. ! ! Structures with a dip of 0 are not projected ! ! To Run ! ! dbgl <this script> ! ! !Parametros locales environment krja ! Selecction of original database assign output1! to text_file using database demo.tek/tek alias db1 ! First group to be executed define initialize always ! Variables to diferenciate new objects in ascii file mx = 0 ; my = 1 ; planta = 0 ; length = 0 ; text_file = "text.txt" ; siascii = "N" ; ! Input of target RL output! = "Cota Planta a la que desea proyectar las estructuras :" ; planta = input? ; ! Do you want an ASCII file output! = "desea generar un archivo ASCII con la proyeccion de las lineas <s/n> : " ; siascii = input? . ! If you want an ASCII file Input the length ! of the projected line if upcase(siascii) eq "S" then output! = "Longitud de la linea proyectada : " ; length = input? ; length = length / 2 . always dbase1 = " " ; stop "end of init" . end of initialize definition !Demotemp.tek database generation generate demotemp.tek/tek alias db3 if no_more_data(db1) then stop " Proyeccion terminada" . if current_record(db1:header) then db3:header = db1:header ; save db3:header . if current_record(db1:geotec) then dh = planta - db1:geotec:elev ; db3:geotec = db1:geotec ; db3:geotec:elev = db1:geotec:elev+dh . if db1:geotec:dip ne 0 and current_record(db1:geotec) then db3:geotec:amgest = db1:geotec:amgest + (dh/tan( db1:geotec:dip/57.295779))*sin((db1:geotec:dipdir-180)/57.295779) ; db3:geotec:amgnth = db1:geotec:amgnth + (dh/tan(db1:geotec:dip/57.295779))*cos((db1:geotec:dipdir-180)/57.295779) . !Generacion de Ascii if upcase(siascii) eq "S" then topx = db3:geotec:amgest+length*sin((db1:geotec:dipdir-90)/57.295779) ; topy = db3:geotec:amgnth+length*cos((db1:geotec:dipdir-90)/57.295779) ; topz = db3:geotec:elev ; botx = db3:geotec:amgest-length*sin((db1:geotec:dipdir-90)/57.295779) ; boty = db3:geotec:amgnth-length*cos((db1:geotec:dipdir-90)/57.295779) ; botz = db3:geotec:elev ; output1! = format(topx,"F15.3") & format(topy,"F15.3") & format(topz,"F15.3") & format(my,"F15.3") ; output1! = format(botx,"F15.3") & format(boty,"F15.3") & format(botz,"F15.3") & format(mx,"F15.3") . if current_record(db1:geotec) then save db3:geotec . always read db1 . end of db3 generation
Was this page helpful?