--- parser3/src/classes/table.C 2001/10/31 14:08:36 1.129 +++ parser3/src/classes/table.C 2001/11/22 15:47:12 1.133 @@ -2,9 +2,9 @@ Parser: @b table parser class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: table.C,v 1.129 2001/10/31 14:08:36 paf Exp $ + $Id: table.C,v 1.133 2001/11/22 15:47:12 paf Exp $ */ #include "classes.h" @@ -208,8 +208,22 @@ static void _offset(Request& r, const St Pool& pool=r.pool(); Table& table=static_cast(r.self)->table(); if(params->size()) { - Value& offset_expr=params->as_junction(0, "offset must be expression"); - table.shift(r.process(offset_expr).as_int()); + bool absolute=false; + if(params->size()>1) { + const String& whence=params->as_string(0, "whence must be string"); + if(whence=="cur") + absolute=false; + else if(whence=="set") + absolute=true; + else + throw Exception(0, 0, + &whence, + "is invalid whence, valid are 'cur' or 'set'"); + } + + + Value& offset_expr=params->as_junction(params->size()-1, "offset must be expression"); + table.offset(absolute, r.process(offset_expr).as_int()); } else { Value& value=*new(pool) VInt(pool, table.current()); value.set_name(method_name); @@ -602,8 +616,9 @@ MTable::MTable(Pool& apool) : Methoded(a add_native_method("line", Method::CT_DYNAMIC, _line, 0, 0); // ^table.offset[] - // ^table.offset[offset] - add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 1); + // ^table.offset(offset) + // ^table.offset[cur|set](offset) + add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 2); // ^table.menu{code} // ^table.menu{code}[delim]