!
! @ SAYALL Variable
!       will display the command
! Let Variable 'Variable_value'
!
! Works for all variables, of any kind and dimensions, provided
! the dimensions are small enough. Parameter MXY sets the maximum dimension
! allowed
!
define integer dims[5] types ixy mxy
let mxy 256  ! Maximum size of array
let types typeof(&1)
if (types.eq.0) then
   message e sayall "Variable &1 does not exist"
   return error
endif
compute dims dimof &1
!
if (types.gt.0) then
!
! Character Strings & Arrays
  if (dims[5].eq.0) then
     say "let &1 " """" '&1' """" /format a a a a
  else if (dims[5].eq.1) then
     if (dims[1].lt.mxy) then
        for i 1 to dims[1]
        say "let &1["'i'"] " """" '&1[i]' """" /format a a a a
        next
     else
        message e sayall "Character array &1 too large "'dims[1]'
        return error
     endif
  else
     message e sayall "Does not handle that yet ..."
     return error
  endif
else
!
! Arithmetics...
  if (dims[5].eq.0) then ! Scalar
     say "let &1 "'&1'
  else if (dims[5].eq.1) then
     if (dims[1].lt.mxy) then
        for i 1 to dims[1]
           say "Let &1["'i'"] "'&1[i]'
        next
     else
        message e sayall "Array too large "'dims[1]'
        return error
     endif
  else if (dims[5].eq.2) then
     let ixy dims[1]*dims[2]
     if (ixy.lt.mxy) then
        for j 1 to dims[2]
           for i 1 to dims[1]
             say "Let &1["'i'","'j'"] "'&1[i,j]'
             next
        next
     else
        message e sayall "Array too large "'dims[1]' 'dims[2]'
        return error
     endif
  else if (dims[5].eq.3) then
     let ixy dims[1]*dims[2]*dims[3]
     if (ixy.lt.mxy) then
        for k 1 to dims[3]
        for j 1 to dims[2]
        for i 1 to dims[1]
             say "Let &1["'i'","'j'","'k'"] "'&1[i,j,k]'
        next
        next
        next
     else
        message e sayall "Array too large "'dims[1]' 'dims[2]' 'dims[3]'
        return error
     endif
  else if (dims[5].eq.4) then
     let ixy dims[1]*dims[2]*dims[3]*dims[4]
     if (ixy.lt.mxy) then
        for l 1 to dims[4]
        for k 1 to dims[3]
        for j 1 to dims[2]
        for i 1 to dims[1]
             say "Let &1["'i'","'j'","'k'","'l'"] "'&1[i,j,k,l]'
        next
        next
        next
        next
     else
        message e sayall "Array too large "'dims[1]' 'dims[2]' 'dims[3]' 'dims[4]'
        return error
     endif
   endif
endif
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
