Op dinsdag 15 juli 2014 00:17:20 UTC+2 schreef jckrell:
The easiest thing would be for your cgi script to return some html code. So if it's succesful, have it return a different value then when it has failed. That way, in the powerbuilder code, you can call the url and use the return html to determine if your perl script was a success.
As for calling a perl script; I'm going to assume it'll run on a server somewhere so you can trigger it by calling a URL. If so, then the following will apply:
Create a new Standard Class. When prompted, choose the internetresult class. In the newly created class you'll need to program the internetdata (blob data) function. This class will be used when calling a URL and the internetdata function is a standard function that handles the result your receive from the URL. Typically the blob will be ANSI encoded, so you'll want to convert it. Just put the result into an instance variable would be my suggestion:
is_return = String(data, EncodingANSI!)
From the place where you want to call your perl script, you then need to initialize your new class as well as the class INET:
n_internetresult_yourclass lv_ir_yourclass
inet lv_inet
lv_ir_yourclass = create n_internetresult_yourclass
lv_inet = create inet
The inet class is then used to call your URL, your internetresult class will handle the HTML you get back:
lv_inet.getUrl('address-of-your-perl-script', lv_ir_yourclass)
And you can retrieve the result (which should contain the variabele html, telling you if the perl script was successful) from the instance variabele:
lb_result = lv_ir_yourclass.is_return = 1
And with that, you can now do whatever you wish to do in the case of a sucessful action or a not so successful one:
if lb_result then
MessageBox('Huzzah!', 'It worked!')
else
MessageBox('Boo!', 'Drat; didn't work...')
end if