Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: sheng l. on April 29, 2015, 06:48:57 am



Title: Compile Failed with both Import com & Import java com.google.gdata...
Post by: sheng l. on April 29, 2015, 06:48:57 am
Hi all

I can not compile following code

import com
import util


##-----------------------------------------------------------------------------youtube_video_processed
function youtube_video_processed( youtube_video_id)

define
   youtube_video_id         string,
   req                     com.HTTPRequest,
   resp                  com.HTTPResponse,
   url                     string,
   api_key                  string


   let api_key = "myapikey"
   let url = sfmt('https://www.googleapis.com/youtube/v3/videos?id=%1&key=%2&part=snippet,contentDetails,statistics,status',
               youtube_video_id CLIPPED,
               api_key CLIPPED)

   let req = com.HTTPRequest.Create(  url  CLIPPED)
   call req.doRequest()
   let resp = req.getResponse()
   let text_response = resp.getTextResponse()

return ""
end function



| cannot find symbol HTTPRequest, location: package com.
| See error number -6632.


Title: Re: Compile Failed with both Import com & Import java com.google.gdata...
Post by: sheng l. on April 29, 2015, 07:00:48 am
Hi

When I'm using youtube java libraries (name begin with com.somgthing) such as "import java com.google.gdata.client.youtube.YouTubeService", the compiler will be confused if I also use import com at the same time... and give me the error below


import com
import java com.google.gdata.client.youtube.YouTubeService


##-----------------------------------------------------------------------------youtube_video_processed
function youtube_video_processed( youtube_video_id)

define
   youtube_video_id         string,
   req                  com.HTTPRequest,
   resp                  com.HTTPResponse,
   url                  string,
   api_key               string,
   text_response            string


   let api_key = "myapikey"
   let url = sfmt('https://www.googleapis.com/youtube/v3/videos?id=%1&key=%2&part=snippet,contentDetails,statistics,status',
               youtube_video_id CLIPPED,
               api_key CLIPPED)

   let req = com.HTTPRequest.Create(  url  CLIPPED)
| cannot find symbol HTTPRequest, location: package com.
| See error number -6632.
   call req.doRequest()
   let resp = req.getResponse()
   let text_response = resp.getTextResponse()

        display text_response CLIPPED
 
return
end function



I have no idea how the first one was posted........  lol


Title: Re: Compile Failed with both Import com & Import java com.google.gdata...
Post by: Rene S. on April 29, 2015, 09:49:46 am
Hello,

this is a known bug: FGL-3887 IMPORT com and IMPORT JAVA com conflicts

Some details:

MPORT JAVA com.xxx.zzz adds the symbol "com" in the symbol table.
IMPORT com tries to add the symbol "com" again.

Compare this with:
Code
  1. DEFINE foo RECORD f1, f2 STRING END RECORD
  2. DEFINE foo INT
  3.  

Rene


Title: Re: Compile Failed with both Import com & Import java com.google.gdata...
Post by: sheng l. on April 29, 2015, 10:44:14 pm
Ok, I will separate them into different modules for now.

Cheers!


Title: Re: Compile Failed with both Import com & Import java com.google.gdata...
Post by: Christine R. on April 30, 2015, 03:01:50 pm
Hello,

The workaround is effectively to separate the FGLGWS code in one file and the JAVA code in another one.
You then just need to link both files in the .42r.
Attached a little example showing this.

To compile it, run :
fgl2p -M -o jtest.42r jtest.4gl jtest2.4gl

Best regards,

Christine