BAP Online Manuals : Library Reference : Library by Name : getbacktrack
Previous: get
Next: get_my_id

6.2.65. getbacktrack

gets backtrack point

SYNOPSIS

getbacktrack(BTP)

SYNTAX

getbacktrack(BackTrackPoint) (i)

ARGUMENTS

integer(BackTrackPoint) (i) A value to be passed to cutbacktrack.

DESCRIPTION

Together with cutbacktrack() () this predicate may be used to effect backtracking. Its effect is, that when backtracking takes place back to the cutbacktrack() goal, the execution flow takes a short-cut back to the position where the associated getbacktrack() goal was done.
Instead of using getbacktrack() and cutbacktrack() you may also use set_cut () and cut () to achieve the same purpose. set_cut()/cut() are more comfortable in a way that you may use virtual handle, but they work sufficiently slower.

EXAMPLE

repeat,
	getbacktrack(BTP),
	for(1,5,X),
		write(X),
		X = 3,
		cutbacktrack(BTP),
		fail.

This will cause the following output:

123123123 ...

ERRORS

A runtime error occurs if BackTrackPoint is bound. However, misuse may crash the system.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

! , set_cut , cut , cutbacktrack


BAP Online Manuals : Library Reference : Library by Name : getbacktrack
Previous: get
Next: get_my_id