在Eiffel中也得到错误“VEVI:变量未正确设置”

时间:2016-11-02 16:16:46

标签: agent eiffel

我正在尝试制作代理商" print_min_fold" for a linked_list" folds"在埃菲尔:

------------------------ Schnipp:

class PF_HP


create
 make

feature --Queries:
--  n : NONE;

grid: separate GRID;

seq: BOOL_STRING;
strseq: STRING;
iseq: INTEGER;

zero, one: BOOLEAN;

fold: STRING;

folds: LINKED_LIST[STRING];

losses, indices: LINKED_LIST[INTEGER];
 -- indices: ARRAY[INTEGER];

i: INTEGER;
loss, min: INTEGER
 --Constructor:

make
  do

min:=9999
loss:=0

 from
  io.put_string("                           123456789012345%N")
  io.put_string ("Bitte Bitsequenz eingeben: ")
  io.read_line
 until
        (not io.last_string.is_empty) --and then io.last_string.is_bit
 loop
   io.put_string("%N")
   io.put_string("Keine Bitsequenz eingegeben. Besteht nur aus 0 und 1 in beliebiger Reihenfolge!%N")
     io.put_string("                           123456789012345%N")
     io.put_string ("Bitte Bitsequenz eingeben: ")
     io.read_line
   end
-- iseq:=io.last_integer
 strseq:=io.last_string
 create folds.make
 create losses.make
 create indices.make --from_collection(losses)
 create fold.make(strseq.count-1)
 create seq.make(strseq.count)
 --create zero.make

zero:=False
one:=True

---------------------------等...

 print_min_fold
do
  folds.do_all( agent print_item(?) )

end

 print_item(item: STRING)
    do
     number := number + 1
     io.put_character('#')
     io.put_integer(number)
     io.put_character(' ')
     io.put_string(item)
     io.put_character('%N')
  end -- print_item

----------------------------------- Schnapp

我得到的错误是:

Error code: VEVI

Error: variable is not properly set.
What to do: ensure the variable is properly set by the corresponding
setter instruction.

Class: PF_HP
Feature: print_min_fold
Creation procedure: make declared in PF_HP
Attribute(s): grid
Line: 400
do
->    folds.do_all( agent print_item(?) )

1 个答案:

答案 0 :(得分:3)

print_min_fold附加对象之前看起来grid被调用。您需要在grid被调用之前初始化print_min_fold

或者您可以将grid标记为detachable separate,但是在对其进行任何调用之前,您必须使用对象测试来确保它不是无效的。