我在SWI-Prolog中定义变量有一些奇怪的(或不那么奇怪的)问题。例如:
我想做类似下面的事情:
:- initialization(main).
main :-
X = listing(main),
write(X).
但它只是打印"列出(主要)"
答案 0 :(得分:2)
您正在使用X = listing(...)
创建一个术语,稍后您将使用write进行打印。
您似乎想要访问main的代码。你要找的东西是clause/2
:
子句(:头,?身体)
如果Head可以与子句head和Body与相应的子句主体统一,则为true。提供回溯的替代条款。事实上,身体与原子是统一的。
示例:
main :- clause(main, X), write(X).
?- main.
clause(main,_G2381),write(_G2381)
true.
答案 1 :(得分:2)
也许,使用另一个临时谓词而不是main / 0 ......
private Font f = new Font("Arial", 7);
public Form1()
{
InitializeComponent();
pictureBox1.Paint += pictureBox1_Paint;
}
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Invalidate();
}
void pictureBox1_Paint(object sender, PaintEventArgs e)
{
int localReadX = ReadAddress("hl2", "client.dll+0xBFFF00 364 0");
int localReadY = ReadAddress("hl2", "client.dll+0xBFFF00 368 0");
byte[] bytesOflocalX = BitConverter.GetBytes(localReadX);//converts to float
byte[] bytesOflocalY = BitConverter.GetBytes(localReadY);//converts to float
float localX = BitConverter.ToSingle(bytesOflocalX, 0) / 10;//converts to float
float localY = BitConverter.ToSingle(bytesOflocalY, 0) / 10;//converts to float
e.Graphics.FillRectangle(Brushes.Red, localX, localY, 5, 5);
e.Graphics.DrawString(" local", f, Brushes.Red, localX, localY);
}