使用 SET PROCEDURE TO 时出错 [英] Getting Error When Using SET PROCEDURE TO

查看:21
本文介绍了使用 SET PROCEDURE TO 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我说,我对 FoxPro 非常非常陌生,只是发现基础知识有点学习曲线.

First let me say that I am very, very new to FoxPro and finding just the basics a bit of a learning curve.

我正在尝试创建一个程序文件 (.prg),其中包含一些可以从主代码调用的公共函数.我添加了程序文件publicfunctions.prg"并包含一个简单的函数,它返回一个硬编码的文字(只是试图让机制工作)

I am attempting to create a program file (.prg) that has some public functions that I can call from my main code. I have added the program file "publicfunctions.prg" and included a simple function that returns a hard coded literal (just trying to make the mechanics work)

*!* This function is in the publicfunctions.prg file
FUNCTION GetFieldValue
    RETURN 'This is the value'
ENDFUNC

然后在我的主程序中我尝试使用它,但我收到文件不存在的错误.这是主程序中的全部代码

Then in my main program I attempt to use it but I am getting the error that the file does not exist. Here is the entirety of the code in the main program

*!* This is the main program logic    
SET PROCEDURE TO publicfunctions.prg

PRIVATE sFieldValue = ''

sFieldValue = GetFieldValue()

我得到的错误是SET PROCEDURE TO publicfunctions.prg"语句.它是:文件'publicfunctions.prg"不存在."

The error that I am getting is on the 'SET PROCEDURE TO publicfunctions.prg' statement. It is: "File 'publicfunctions.prg" does not exist."

我猜它找不到它,因为默认目录没有设置为文件所在的路径.我尝试在SET PROCEDURE TO"语句之前添加SET DEFAULT TO"语句,但它根本没有改变结果.

I'm guessing that it can't find it because the default directory is not set to the path where the file exists. I tried adding the "SET DEFAULT TO" statement prior to the "SET PROCEDURE TO" statement but it didn't change the outcome at all.

我不想对路径进行硬编码,所以我想我的问题是:

I don't want to hard code the path so I guess my questions are these:

  1. 我对默认目录的假设是否正确?
  2. 如果#1 为真,那么如何将默认目录设置为主程序文件所在的目录?
  3. 我是否正确调用了该函数?(当然如果能找到的话)

更新
根据以下汉克的问题,我添加了以下附加信息:使用项目管理器上的新建"按钮将文件publicfunctions.prg"添加到项目中,物理文件位于"旁边Main.prg" 文件系统文件夹中的文件.

UPDATE
Per Hank's questions below I have added this additional information: The file "publicfunctions.prg" was added to the project using the "New" button on the Project Manager and the physical file is sitting right next to the "Main.prg" file in the file system folder.

我使用的是 Microsoft Visual FoxPro 9.0

我们将不胜感激任何和所有帮助.

Any and all help will be truly appreciated.

谢谢,
道格

推荐答案

VFP 维护一个搜索路径(与 Windows/DOS 搜索路径分开),它将搜索您在其中引用的任何 PRG、DBF 等您的代码.

VFP maintains a search path (which is separate from the Windows/DOS search path), which it will search for any PRGs, DBFs, etc that you reference in your code.

您可以使用 SET('PATH') 函数检查其当前设置,并使用 SET PATH TO 进行设置.除了当前的默认目录(您可以使用 SET('DEFAULT') 和 CURDIR() 函数进行验证)之外,还会搜索这些位置.

You can check its current setting with the SET('PATH') function, and set it with SET PATH TO. These places are searched in addition to whatever the current default directory (which you can verify with the SET('DEFAULT') and CURDIR() functions.

这将显示这些当前是什么:

This will show what these currently are:

WAIT WINDOW 'Path: ' + SET('PATH') + CHR(13)+CHR(10) + 'Default drive: ' + SET('Default') + CHR(13)+CHR(10) + 'Current directory: ' + CURDIR()

这些在 VFP 的帮助中有很好的记录 - 检查那里以获得更好的解释.

These are documented well in VFP's help - check there for a much better explanation.

这篇关于使用 SET PROCEDURE TO 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆