Welcome! Log In Create A New Profile

Advanced

HReadSeekFirst error using ExecuteProcess

Posted by Mark Crichton 
HReadSeekFirst error using ExecuteProcess
March 16, 2019 11:33PM
Hi

Have have a user code edit control for dynamic code.

It has following in it

HOpen(fixaddress)
HReadFirst(fixaddress)
Info("Test line 1 - " + fixaddress.adrname)

HReadSeek(fixaddress,adrname,"Sa")
Info("Seek line 1 - " + fixaddress.adrname)

The code that executes the script is

sRptSql is Procedure = Compile("ProcRptSql",edt_rptsql)
IF ErrorOccurred = False THEN
ExecuteProcess("ProcRptSql", trtProcedure) // used to use sRptSql()

ELSE
// other code here ...
END

When I run it,
the first info gives me the first lines company name s correctly

I then get the following error.

Script has returned an exception error
Element 'adrname' is unknown

the field adrname is an index field for fix address.

Database id HFSQL server

PS the code works perfectly when part of the application, so not a problem with the database.

Could this command be excluded from the available runtime user functions.. I could not find the list on the windev help.

any help appreciated
regards
Mark



Edited 1 time(s). Last edit at 03/16/2019 11:34PM by Mark Crichton.
Re: HReadSeekFirst error using ExecuteProcess
March 17, 2019 01:18AM
Hi Mark,

I don't think it is good practice to use Info() inside a compiled procedure.
So you probably need to restrict your code to simply return a result and then display the result.
If you need to return multiple results, combine them using a TAB or some other delimiter.
The code should work, but I have my doubts about the info or any direct use of GUI elements, since compile is completely unaware of program context. (except for file items and global variables)

So the edit should contain something like:
sResult is string
HReadFirst(fixaddress) 
sResult=fixaddress.adrname 
HReadSeek(fixaddress,adrname,"Sa") 
sResult+=TAB+"Seek line 1 - "+fixaddress.adrname) 
RESULT sResult
Then you display the results using
sResult is string
sResult=ExecuteProcess("ProcRptSql", trtProcedure)
Compile("ProcRptSql", "") //cleanup the procedure
Info(Extractstring,sResult,1)
Info(Extractstring,sResult,2)

BTW, with HFSQL you don't need to open any files.
I have used complex compiled procedures without any problems this way, even using queries and declaring and using classes inside it.

Best regards,
Piet



Edited 2 time(s). Last edit at 03/17/2019 01:21AM by pietvanz.
Re: HReadSeekFirst error using ExecuteProcess
March 17, 2019 01:26AM
Hi Piet

Thanks for the advice. In this case I am using the info to debug the code, and they are removed once all working ok.

Yes I do normally return results in the way you suggest.

using hopen only because I can prove that I have table open and on first record. ie: first info message returns first record name.

Maybe you can help with my problem which is why does HReadseekfirst not work pithing my compile procedure. What is upsetting it?
I am still try to find it. HFilter code I've now tried does work ok.
Re: HReadSeekFirst error using ExecuteProcess
March 17, 2019 01:35AM
PROBLEM SOLVED smiling smiley

When using the compile + ExecuteProcess the syntax has to be

HReadSeek(fixaddress,"adrname","Sa")
and NOT
HReadSeek(fixaddress,adrname,"Sa")

It must have the inverted commas around the index name.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: