1. LUIZ A augusto manzella
  2. PowerBuilder
  3. Thursday, 11 February 2021 00:08 AM UTC
how do you declare the variables ir and n_ir? the code below shows the error:

error: c0047: Simple datatype illegal for crate statemant: n_ir


lob lblb_args
String ls_headers
String ls_url
String ls_args
long ll_length
integer li_rc
Inet ir

li_rc = GetContextService( "Internet", iinet_base )
IF li_rc = 1 THEN ir = CREATE n_ir ls_url = "http://localhost/Site/testurl.stm?"
ls_args = "user=MyName&pwd=MyPasswd"
lblb_args = Blob( ls_args )
ll_length = Len( lblb_args )
ls_header = "Content-Type: " + &
"application/x-www-form-urlencoded~n" + &
"Content-Length: " + String( ll_length ) + "~n~n"
li_rc = iinet.PostURL( ls_url, lblb_args, &
ls_header, ir )
END IF
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 12 February 2021 12:49 PM UTC
  2. PowerBuilder
  3. # 1

I know in your code example you use a localhost url, but is the actual "live" url external?  The reason I ask is because most scenarios like you have here where you just post some data have been converted to web services, which is a much better solution than using the inet object and post url.  If it's an internal app, you might want to talk to the owner about exposing the functionality as a REST web service.  If it's external, maybe it already has an API.

 

KR

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 11 February 2021 19:55 PM UTC
  2. PowerBuilder
  3. # 2

Hi Miguel;

   FWIW: The "GetContectService" should be replaced with a CREATE. The GCS command works (for now), but its actually is an old EAServer left over.  ;-)

Regards ... Chris

Comment
  1. Miguel Leeuwe
  2. Friday, 12 February 2021 00:29 AM UTC
Okay Chris, thanks for that, I just today applied one in our code, let me change it!

:)
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 11 February 2021 01:09 AM UTC
  2. PowerBuilder
  3. # 3

Hi, Luiz -

A PowerBuilder inet object is a service object, so you instantiate it via the GetContextService PowerScript function:

integer li_rc
inet    linet

li_rc = GetContextService("internet", linet)

The PFC object n_ir is not a descendant of the inet object. It is instead a descendant of the internetresult object, which is different from the inet object. You can verify this by using Edit Source on pfc_n_ir in the pfcmain.pbl.

In questions like this, the "System" tab of the PB Object Browser window is your friend. In the left-side pane, right-click and select "Expand All", then scroll down to and click (select) inet, then right-click and select "Show Hierarchy" - and you'll see that inet is a descendant of the service object, as are the contextinformation, contextkeyword, errorlogging, sslserviceprovider and transactionverver system objects.

Regards, John

Comment
  1. Miguel Leeuwe
  2. Thursday, 11 February 2021 03:20 AM UTC
yes, you're right about n_ir not being an 'inet' object and not having to do a Create. (I didn't even know that one existed in the pfcs, never used it as far as I can remember. So I assumed it had to be something the op created himself, lol)

regards
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 11 February 2021 00:24 AM UTC
  2. PowerBuilder
  3. # 4

Hi,

EDITED: I was wrong, John was right, I've corrected the code.

Probably you have to change the declaration of "ir":

Change the line: "Inet ir" to: "n_ir ir"

n_ir is probably an object inherited from inet

Also, there's an error in the line:

IF li_rc = 1 THEN ir = CREATE n_ir ls_url = "http://localhost/Site/testurl.stm?"
There's a ";" missing after "create n_ir"
Personally y don't like putting more than one statement on a single line but you can do so.
I would do:
inet linet
integer li_rc

li_rc = GetContextService("internet", linet)
ls_url = "http://localhost/Site/testurl.stm?"
linet.HyperlinkToURL( ls_url )
 
Comment
  1. LUIZ A augusto manzella
  2. Thursday, 11 February 2021 11:31 AM UTC
Thanks! I did, but it didn't work..



After change:

error c0001: illegal data type: n_ir

warning c0014: undefined variable: ir

error c0047: simple datatype fro creater statemant: n_ir









  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 11 February 2021 11:42 AM UTC
Yes, I was wrong, JOHN was right!

(I've edited my answer to correct my error).

sorry!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.