The 4th one works, but kind of blows everything up because of the different files the function uses which interferes with the files I have open. This is why I’d like to start the procedure or function. It was a procedure and I changed it to a function trying to get this thing to work. I tried the ‘500’ because wo:ordernum is actually a long, so a string like the docs says, just gives me errors, unknown function label and invalid prototype. Any suggestions would be appreciated.
Thank you
The only thing returned by STARTing a new thread is the thread number, so you can’t return a value from a function called with START.
Your easiest solution is to resolve your issues with option 4.
Maybe by using alias files in the called procedure?
Maybe have a look at UseType in the help, you should be able to call a procedure and not interfere with the current file pointers? The default is UseType:Uses which I think will prevent changing the buffer in your calling procedure, you probably don’t want UseType:Returns.
Remind_Trigger must be prototyped as
(String pOrderNum]
It should likely be “declared globally”.
It cannot return anything because the caller thread continues immediately. The two then proceed independently.
There are ways to Save and Restore your File settings if you need for it to be “not a thread” without resortung to as Alias. But as long as the task is independent of the caller, a thread is a good way to go.
wo:ordernum is a long… I can transfer it to a string variable and make the prototype a string. Now I realize changing it to a function was a mistake, of course I can’t receive anything back, nor do I need to… was just grasping. I’ll try it tomorrow. Thanks.
Doesn’t matter that it’s a long. As long as the receiver (remind_trigger) prototypes it as a string you’re fine. The conversion will happen automatically.
Equally in remind_trigger, presumably you’ll want to open the file and load the record. And it’s fine to just
wo:OrderNum = pOrderNum
it’ll convert as necessary.
Ok, that all worked. It still messed up a screen I was calling it from because I was using jhtml to read and write the html from and to a memo before I merged the data. I took it out and all was good. Turns out my code doesn’t care if it’s html or just plain text, the merge function I have just works either way. I create reminder templates, it has tokens which can be put into the template (a text or html memo). When it creates the reminder which is usually an Email ready to be sent, it merges the data. It was doing labor which could have a category that could trigger a reminder template, so now I wanted it to do parts as well. I use this software for our sales and subscriptions so I’m adding stuff for us as well as our customers. Anyway, got it working great thanks to all the help here. All I did was change the proc to use a string (and no return variable) and all the errors magically went away.
A possible problem with calling this procedure in a new thread is for the calling procedure to know whether it achieved what you wanted it to. Difficult to know if this is a factor in your case because you haven’t told us what the procedure is actually meant to do. There are ways to tell the calling procedure if the called procedure was successful.