c %W% %G%
c
c  program  test_ask_general
c
c  Test ASK subroutines askc, askjnl, askrd, askpr, aski4l.
c
c  M Webring, USGS, 4/96


	character   p1*800,  lf*1, cr*1
	character   prompt*80, jfile*80, txtrec*160

	call askin

        jfile  = 'testaskg.jnl'
	jnlunt = 11

c  Journaling

	notyet = 1

        ians = 0
10	continue
        call aski4l( 'Journaling ?', ians, kboard )
	if ( kboard .eq. -2 ) go to 888

c  Deactivate.

        if ( ians .eq. 0  .and.  notyet .eq. 0 ) then
          call askjnl( 'w', 0, ians, ierror )
	  print *, ' journaling deactivated.'
        endif


c  Reactivate.

	if ( ians .eq. 1  .and.  notyet .eq. 0 ) then
          call askjnl( 'w', 0, ians, ierror )
	  print *, ' journaling reactivated.'
        endif


c  Open the journal file and active.

        if ( ians .eq. 1  .and.  notyet .eq. 1 ) then

          prompt = 'Enter journal filename'
          call askc( prompt, jfile, kboard )
          if ( kboard .eq. -2 ) go to 10

          open( unit=jnlunt, file=jfile,
     1    form='formatted', status='unknown' )

          jnlact = 1
          call askjnl( 'w', jnlunt, jnlact, ierror )

          if ( ierror .ne. 0 ) then
            print *, ' Main: askjnl returned an error '
            print *, ' jnlunt, jnlact =', jnlunt, jnlact
	    go to 10
          endif

	  call gclast( jfile, nchj )
	  prompt = 'journal filename =' // jfile(1:nchj)
	  call askpr( prompt )

	  notyet = 0
        endif


c  Test of ASKPR.

	cr = char( 13 )
	lf = char( 10 )

	p1 = lf //
     1  '  Test ASK subroutines:' // lf //
     1  ' askc, aski4l, askjnl, (indirectly askrd, askpr, askyn).' //
     1  lf // lf //
     1  ' The mu' //
     1  ' response is triggered by being the only entry.  CTL-EOT' //
     1  ' may or may not cause an immediate mu response depending' //
     1  ' on the particular host hardware.' // lf // lf

	call askpr( p1 )

	txtrec = ' '

50	prompt = 'Enter a text string'

	call askc( prompt, txtrec, kboard )
	if ( kboard .eq. -2 ) go to 10

	prompt = lf // ' ASKC text string>>'
	call askpr( prompt )
	call askpr( txtrec )
        call askalt()
	call askpr( '<<end of text string' )
        call askalt()
	go to 50


888     if ( notyet .eq. 0 ) then
          close( jnlunt )
        endif

999	stop
	end
