Thread: syntax error when running a SAC macro

Started: 2013-08-01 18:25:45
Last activity: 2013-08-02 16:06:34
Topics: SAC Help
jiajun chong
2013-08-01 18:25:45
Hi there,

I have a problem when running a SAC macro using sac101.6, but it works
well with older version. I don't know what's going on. Is there anyone can
help me?

the error information: Syntax error: setbb radial '(CHANGE 'HZ' 'HR'
%vert)'

and here is the SAC macro as following:



sc mkdir Trash
sc mkdir GoodOnes
qdp off
do file wild *HZ.sac
setbb vert $file
setbb radial '(CHANGE 'HZ' 'HR' %vert)'
setbb tang '(CHANGE 'HZ' 'HT' %vert)'
r %vert %radial %tang
bp n 4 c 0.005 0.05
rmean
rtr
p1

setbb resp (REPLY "Enter t to trash the file")
if %resp eq "t" then
sc mv %vert Trash
sc mv %radial Trash
sc mv %tang Trash
else
sc mv %vert GoodOnes
sc mv %radial GoodOnes
sc mv %tang GoodOnes

endif
enddo


Best Regards,

Jiajun Chong

--
Jiajun Chong

**Postdoctoral Fellow
Institute of Earth Sciences, Academia Sinica

http://www.earth.sinica.edu.tw/~jiajun/Postdoc_chongjiajun_e.html

  • Brian Savage
    2013-08-01 19:39:13
    Dear Jiajun Chong,

    Try removing the ticks, or quotes, ' from the setbb / change line

    setbb radial '(CHANGE 'HZ' 'HR' %vert)'
    to
    setbb radial (CHANGE 'HZ' 'HR' %vert)


    setbb vert filename.BHZ.sac
    setbb radial (CHANGE 'HZ' 'HR' %vert )
    ==> setbb radial filename.BHR.sac

    setbb tang (CHANGE 'HZ' 'HT' %vert )
    ==> setbb tang filename.BHT.sac

    message %vert %radial %tang
    ==> message filename.BHZ.sac filename.BHR.sac filename.BHT.sac
    filename.BHZ.sac
    filename.BHR.sac
    filename.BHT.sac

    The new version, 101.6, thinks that the original line is a quoted character string and does not do variable interpolation inside the quotes. Removing the external quotes should fix your error.

    Brian

    On Jul 31, 2013, at 11:25 PM, Jiajun Chong wrote:

    Hi there,

    I have a problem when running a SAC macro using sac101.6, but it works well with older version. I don't know what's going on. Is there anyone can help me?

    the error information: Syntax error: setbb radial '(CHANGE 'HZ' 'HR' %vert)'

    and here is the SAC macro as following:



    sc mkdir Trash
    sc mkdir GoodOnes
    qdp off
    do file wild *HZ.sac
    setbb vert $file
    setbb radial '(CHANGE 'HZ' 'HR' %vert)'
    setbb tang '(CHANGE 'HZ' 'HT' %vert)'
    r %vert %radial %tang
    bp n 4 c 0.005 0.05
    rmean
    rtr
    p1

    setbb resp (REPLY "Enter t to trash the file")
    if %resp eq "t" then
    sc mv %vert Trash
    sc mv %radial Trash
    sc mv %tang Trash
    else
    sc mv %vert GoodOnes
    sc mv %radial GoodOnes
    sc mv %tang GoodOnes

    endif
    enddo


    Best Regards,

    Jiajun Chong

    --
    Jiajun Chong

    Postdoctoral Fellow
    Institute of Earth Sciences, Academia Sinica

    http://www.earth.sinica.edu.tw/~jiajun/Postdoc_chongjiajun_e.html
    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help


    • jiajun chong
      2013-08-02 16:06:34
      Dear Brian,

      Thanks so much for your help, it works now, your version looks better
      and will not run into a problem when 'HZ' happens to be in the station
      code.

      Best Regards,

      Jiajun


      On Fri, Aug 2, 2013 at 12:39 AM, Brian Savage <savage<at>uri.edu> wrote:

      Dear Jiajun Chong,

      Try removing the ticks, or quotes, ' from the setbb / change line

      setbb radial '(CHANGE 'HZ' 'HR' %vert)'
      to
      setbb radial (CHANGE 'HZ' 'HR' %vert)


      setbb vert filename.BHZ.sac
      setbb radial (CHANGE 'HZ' 'HR' %vert )
      ==> setbb radial filename.BHR.sac

      setbb tang (CHANGE 'HZ' 'HT' %vert )
      ==> setbb tang filename.BHT.sac

      message %vert %radial %tang
      ==> message filename.BHZ.sac filename.BHR.sac filename.BHT.sac
      filename.BHZ.sac
      filename.BHR.sac
      filename.BHT.sac

      The new version, 101.6, thinks that the original line is a quoted
      character string and does not do variable interpolation inside the quotes.
      Removing the external quotes should fix your error.

      Brian

      On Jul 31, 2013, at 11:25 PM, Jiajun Chong wrote:

      Hi there,

      I have a problem when running a SAC macro using sac101.6, but it works
      well with older version. I don't know what's going on. Is there anyone can
      help me?

      the error information: Syntax error: setbb radial '(CHANGE 'HZ' 'HR'
      %vert)'

      and here is the SAC macro as following:



      sc mkdir Trash
      sc mkdir GoodOnes
      qdp off
      do file wild *HZ.sac
      setbb vert $file
      setbb radial '(CHANGE 'HZ' 'HR' %vert)'
      setbb tang '(CHANGE 'HZ' 'HT' %vert)'
      r %vert %radial %tang
      bp n 4 c 0.005 0.05
      rmean
      rtr
      p1

      setbb resp (REPLY "Enter t to trash the file")
      if %resp eq "t" then
      sc mv %vert Trash
      sc mv %radial Trash
      sc mv %tang Trash
      else
      sc mv %vert GoodOnes
      sc mv %radial GoodOnes
      sc mv %tang GoodOnes

      endif
      enddo


      Best Regards,

      Jiajun Chong

      --
      Jiajun Chong

      **Postdoctoral Fellow
      Institute of Earth Sciences, Academia Sinica

      http://www.earth.sinica.edu.tw/~jiajun/Postdoc_chongjiajun_e.html
      _______________________________________________
      sac-help mailing list
      sac-help<at>iris.washington.edu
      http://www.iris.washington.edu/mailman/listinfo/sac-help





      --
      Jiajun Chong

      **Postdoctoral Fellow
      Institute of Earth Sciences, Academia Sinica

      http://www.earth.sinica.edu.tw/~jiajun/Postdoc_chongjiajun_e.html

20:16:51 v.01697673