Organization: "Centro di Informatica & C.A. - University of Verona - IT"
Newsgroups: bit.listserv.dbase-l
Date:         Mon, 5 Oct 1992 17:47:33 ITA
              dialects" <DBASE-L@NMSUVM1.BITNET>
From:         Germano Rossi <GERMANO@IVRUNIV.BITNET>
Subject:      Array in Clipper 5.01

Hi networkers,

perhaps my question is a FAQ, but I'm new in Clipper 5.01.
Manual say that I can pass array as parameters to a function or a procedure.
But... something doesn't work! Why?
The follow is a program that I copied from a book. Clipper compile it, and
run it, but when I select "Clienti" options, said:
Error BASE/1068 Argument aerror: array access
I try with
IF ! (TYPE("MPROMPTS")="A")
  ALERT("Is not an array", "OK")
ENDIF
after the LOCAL command in LEN_L_PROMPT function
and the ALERT message were display. So, now, I know that the array is not
passed. Why? I compile with /n/a/m parameters. It's correct?

Someone of you can help me?

Thanks in advance, Germano

---------------------------------------------------------------------------
* Compile with /dTEST to "test" the procedure
*
#include "germano.ch"

#ifdef TEST
  procedure menu
    local choice
    local main_menu := { {"Clienti", menu2}, {"Fatture", { nopzio()}}, ;
                      {"Tabelle", { nopzio()}} }
    local menu2 := { {"Inserimento", { nopzio()}}, {"Modifica", { nopzio()}}
, ;
                    {"Stampa", { nopzio()}} }
    desktop()
    choice = do_menu(main_menu, .t.)
  return

  function nopzio
  local x
    ALERT("You are in menu choice", {"OK"})
  return NIL
#endif

function do_menu(mprompts, shadow)
local num_prompts, prompt_num, save_win, choice, cols
  DEFAULT shadow TO VERO
  vstk_push()
  num_prompts = len(mprompts)
  cols = array(num_prompts)
  save_win = savescreen(0, 0, 3, maxcol())
  if shadow
    @ 0, 0 clear to 2, maxcol()-1
    @ 0, 0 to 2, maxcol()-1
    sha_shadow(0, 0, 2, maxcol()-1)
  else
    @ 0, 0 clear to 2, maxcol()
    @ 0, 0 to 2, maxcol()
  endif
  choice = 1
  set wrap on
  do while choice != 0
    @ 1, 0 say ""
    for prompt_num = 1 to num_prompts
      colsprompt_num = col() + 2
      @ 1, col() + 2 prompt mpromptsprompt_num, 1
    next
    menu to choice
    if choice > 0
      if valtype(mpromptschoice, 2) = "B"
        eval(mpromptschoice, 2)
      else
        do_pull_down(mpromptschoice, 2, 3, colschoice, shadow)
      endif
    endif
  enddo
  win_rest(save_win)
  vstk_pop()
return nil

function do_pull_down(mprompts, t, l, shadow)
local save_win, len_longest, num_prompts, b, r, prompt_num, choice
  len_longest = len_l_prompt(mprompts)
  num_prompts = len(mprompts)
  b = t+num_prompts+1
  r=l+len_longest+1
  if shadow .and. b<maxrow() .and. r<maxcol()
    save_win = win_save(t, l, b+1, r+1)
    sha_shadow(t,l,b,r)
  else
    save_win = win_save(t, l, b, r)
  endif
  @ t,l to b,r
  choice=1
  do while choice != 0
  for prompt_num = 1 to num_prompts
    @ t+prompt_num, l+1 prompt pad(mpromptsprompt_num, 1, len_longest)
  next
  menu to choice
  if choice > 0
    if valtype(mpromptschoice, 2) = "B"
      eval(mpromptschoice, 2)
    else
      do_pull_down(mpromptschoice, 2, choice+t+1, l+1+2*(len_longest/3), shado
w)
    endif
  endif
enddo
return NIL

static function len_l_prompt(mprompts)
local longer, i
  longer=mprompts1,1
  for i=1 to len(mprompts)
    if len(longer) < len(mpromptsi, 1)
      longer = m->mprompti,1
    endif
  next
return len(longer)
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU