1. William Beale
  2. PowerBuilder
  3. Thursday, 11 May 2023 11:01 AM UTC

For what it's worth, I've asked ChatGPT to write PowerBuilder code for a few relatively simple functions.  The results were good, often giving me better ways to approach a problem.  Amazing stuff this AI.

Accepted Answer
Arnd Schmidt Accepted Answer Pending Moderation
  1. Thursday, 11 May 2023 12:07 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi William,

I wonder what kind of code you asked for?!

We tried it with datawindows .... Result was crap :-(

Can you give an example?

Regards,

Arnd

Comment
  1. Miguel Leeuwe
  2. Friday, 15 March 2024 09:48 AM UTC
I've asked Chatgpt to generate an example of C#, gmail and oauth, and the result was crap too. (though it did give me some insight, it mostly led me into looking into the wrong stuff).
  1. Helpful
There are no comments made yet.
Denis Proctor Accepted Answer Pending Moderation
  1. Thursday, 21 March 2024 16:53 PM UTC
  2. PowerBuilder
  3. # 1

I’ve found it pretty good at converting code to different languages. Python to JS, and even Pandas to SQL.

Comment
There are no comments made yet.
Benjamin Daniels Accepted Answer Pending Moderation
  1. Tuesday, 19 March 2024 19:56 PM UTC
  2. PowerBuilder
  3. # 2

I tried using ChatGPT to generate code to call AWS Recognistion API. I found the code produced quite helpfull as it done the bulk of the work.

There was some compile errors on the RestClient object which I changed HTTPClient and change arguments. What I liked about the code, although not correct, it provided a design for the flow of logic. You can just apply the correct objects/functions and good to go. Maybe there is a opportunity to build PB based LLM using all the old chatrooms code and online help to learn from.

I used it to generate API call for Azure ComputerVision API as well.

Chat GPT code below.

// Declare necessary variables
string ls_url, ls_request, ls_response
RESTClient lo_restclient

// Set your AWS credentials and region
string ls_access_key = "<YOUR_ACCESS_KEY>"
string ls_secret_key = "<YOUR_SECRET_KEY>"
string ls_region = "<YOUR_REGION>"

// Construct the URL for the Amazon Rekognition API
ls_url = "https://rekognition." + ls_region + ".amazonaws.com/"

// Construct the request JSON with the image data
ls_request = '{"Image": {"Bytes": "' + YourImageBytesHere + '"}, "MaxLabels": 1}'

// Initialize RESTClient and set the necessary properties
lo_restclient = CREATE RESTClient
lo_restclient.URL = ls_url
lo_restclient.HTTPMethod = HTTPMethod.Post
lo_restclient.RequestFormat = DataFormat.JSON
lo_restclient.ContentType = "application/x-amz-json-1.1"
lo_restclient.AddHeader("x-amz-target", "RekognitionService.DetectLabels")
lo_restclient.AddHeader("x-amz-date", String(DateTime(CurrentDate(), CurrentTime()), "yyyy-mm-ddTHH:nn:ss"))

// Sign the request using AWS Signature Version 4
lo_restclient.SignAWSRequest(ls_access_key, ls_secret_key, "rekognition", ls_region, lo_restclient.URL, lo_restclient.HTTPMethod, lo_restclient.RequestHeaders)

// Set the request data
lo_restclient.RequestData = ls_request

// Execute the request
ls_response = lo_restclient.Send()

// Parse and process the response (ls_response) here

// Cleanup
DESTROY lo_restclient

 
 
Comment
  1. Arnd Schmidt
  2. Tuesday, 19 March 2024 20:49 PM UTC
... and you learned something new about date format: "yyyy-mm-ddTHH:nn:ss" .

Is this a hallucination or does this really work?
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 15 May 2023 08:40 AM UTC
  2. PowerBuilder
  3. # 3

Simple:
ChatGPT still needs Appeon training....  to write advance datawindow techniques....

 

Comment
There are no comments made yet.
William Beale Accepted Answer Pending Moderation
  1. Saturday, 13 May 2023 21:31 PM UTC
  2. PowerBuilder
  3. # 4

Without wishing to labour the pros and cons of ChatGPT and AI, as mentioned, I develop software for law enforcement, and one feature of the application is to isolate entities from a narrative or witness statement, save the entities to respective tables, and advise the User if any entity has appeared before. 

After a few trials with ChatGPT, which I assumed used Name and Entity Recognition (NER), I’ve decided to try and code my application to access Azure’s NER in Open AI. (If anyone has coded PB to use ole to access Azure's Open AI, I'd appreciate their advice. I have an Azure account).

By way of example, I posed the following question to Chat GPT and was impressed by the result (It actually recognised an alias/nickname!):

Can you please list the entities, such as people, locations, and time/dates from Thomas Hardy's novel, "The Return of the Native".

Certainly! Here is a list of some key entities from Thomas Hardy's novel, "The Return of the Native":

People:

  1. Clym Yeobright
  2. Eustacia Vye
  3. Damon Wildeve
  4. Thomasin Yeobright
  5. Mrs. Yeobright
  6. Diggory Venn (a.k.a. "The Reddleman")
  7. Captain Vye
  8. Christian Cantle
  9. Grandfer Cantle
  10. Johnny Nunsuch
  11. Charley 

Locations:

  1. Egdon Heath
  2. Blooms-End (Clym Yeobright's home)
  3. Mistover Knap
  4. The Quiet Woman Inn
  5. Budmouth (a nearby seaside town)
  6. Alderworth (Eustacia's grandfather's house) 

Time/Dates:

The events in the novel are set in the late 19th century (the exact time period is not specified in the story). However, specific dates are not emphasized in the narrative. The story unfolds over a period of time, spanning seasons and years. 

Please note that this list may not be exhaustive and there may be other minor characters, locations, and time references in the novel.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 17 May 2023 08:32 AM UTC
I'd be very hesitant to feed Law enforcement information to ChatGPT.
  1. Helpful 2
  1. Andreas Mykonios
  2. Wednesday, 17 May 2023 09:41 AM UTC
:-)
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 12 May 2023 01:46 AM UTC
  2. PowerBuilder
  3. # 5

Hi, William -

I think you should limit your use of ChatGPT to algorithmic suggestions as far as PowerScript code is concerned, as it appears the Match functions it coded are junk and do not work.

I tested three variations of the first two examples that you listed; First, as coded by ChatGPT, second, removing the leading and trailing parentheses in the match regular expression for both, and third, with a proper PB Match Regex:

If Match('2023','(\d{4})') Then
   MessageBox('Test 1-A','Year matches.')
Else
   MessageBox('Test 1-A','Year does not match.')
End If

If Match('2023','\d{4}') Then
   MessageBox('Test 1-B','Year matches.')
Else
   MessageBox('Test 1-B','Year does not match.')
End If

If Match('2023','^[1-2][0-9][0-9][0-9]') Then
   MessageBox('Test 1-C','Year matches.')
Else
   MessageBox('Test 1-C','Year does not match.')
End If

If Match('HoobyDooby','([a-zA-Z]+)') Then
   MessageBox('Test 2-A','HoobyDooby matches.')
Else
   MessageBox('Test 2-A','HoobyDooby does not match.')
End If

If Match('HoobyDooby','[a-zA-Z]+') Then
   MessageBox('Test 2-B','HoobyDooby matches.')
Else
   MessageBox('Test 2-B','HoobyDooby does not match.')
End If

If Match('HoobyDooby','^[a-zA-Z]+$') Then
   MessageBox('Test 2-C','HoobyDooby matches.')
Else
   MessageBox('Test 2-C','HoobyDooby does not match.')
End If

Tests 1-A and 1-B don't match, and 1-C does. The match regex's might be valid in some other language(s), but they're invalid for the PowerScript Match function. Test 2-A doesn't match. Interestingly and unexpectedly, test 2-B does return True. Test 2-C finds the match. To this point, I'm not impressed with ChatGPT's ability to sling PB code.

Maybe someday...

By the way, although you might not have any other PB developers physically alongside of you, I hope you know you have many "virtual" mentors here in the Appeon Community that you can call on. I see from your profile that you've posted over a dozen questions over the past few years, so I hope you continue to utilize us. We're here to help.

Best regards, John

Comment
  1. Arnd Schmidt
  2. Friday, 12 May 2023 09:36 AM UTC
The Match() Function in PowerBuilder it calling for enhancements since... it was released ;-)
  1. Helpful 1
  1. John Fauss
  2. Friday, 12 May 2023 13:34 PM UTC
@Benjamin - Good observation! Yes, test 2-B returns True if the value to be examined contains ANY alphabetic characters. I was surprised because I believed the intent was to determine if the string contains ONLY alphabetic characters, given the context of what William asked ChatGPT to create code to address.

Until such time that ChatGPT "learns" PowerScript (ChatPB, as Chris observed), PB developers need to be extremely dubious of AI-generated PB code. Just because AI-generated code is syntactically correct and compiles does not mean it accomplishes anything meaningful.
  1. Helpful 2
  1. Roland Smith
  2. Tuesday, 16 May 2023 17:47 PM UTC
Match syntax doesn't match standard Regex syntax, unfortunately.
  1. Helpful
There are no comments made yet.
William Beale Accepted Answer Pending Moderation
  1. Thursday, 11 May 2023 22:12 PM UTC
  2. PowerBuilder
  3. # 6

Hi Arnd,

I haven't tried it with datawindows but have asked it on different occasions for code on various functions.  Two examples.

First, I asked it for code to parse a string from free text of a motor vehicle description, ie '2015 red Toyota Crown, VIN a5rt6780000, license ABC-123' - which in reality could be written in any order. 

I develop software for law enforcement and the routine I use for parsing such a string relies much on DB lookup data, or previously entered data of motor vehicles. 

In the ChatGPT code, without lookup data, if the colour, make and model were scrambled, the outcome would fail. So the response I got from ChatGPT was basic albeit to a basic question.

But I confess this response did give me some ideas in regard to using MATCH which I often have trouble getting my head around.  For example, I've never encountered anything like the (\d{4}) for identifying a year, or the MATCH code for the VIN or license.  (I don't pretend to be a gun programmer, I'm self-taught in PB, and I work alone so I have no peer support.  I can forsee ChatGPT being a good workmate).

This is the response I got from ChatGPT:

// Regular expressions for parsing
string yearPattern, colorPattern, makePattern, modelPattern, vinPattern, licensePattern
yearPattern = '(\d{4})' // Matches a four-digit year
colorPattern = '([a-zA-Z]+)' // Matches one or more alphabetic characters
makePattern = '([a-zA-Z]+)' // Matches one or more alphabetic characters
modelPattern = '([a-zA-Z0-9\s]+)' // Matches one or more alphanumeric characters and spaces
vinPattern = '(VIN [\w]+)' // Matches 'VIN' followed by one or more alphanumeric characters
licensePattern = '(license [\w-]+)' // Matches 'license' followed by one or more alphanumeric characters or hyphens

// Parse the input string
string year, color, make, model, vin, license
MatchResult matchResult

matchResult = Match(inputString, yearPattern)
if matchResult.MatchCount() > 0 then
year = matchResult.GetMatch(1)
end if

matchResult = Match(inputString, colorPattern)
if matchResult.MatchCount() > 0 then
color = matchResult.GetMatch(1)
end if

matchResult = Match(inputString, makePattern)
if matchResult.MatchCount() > 0 then
make = matchResult.GetMatch(1)
end if

matchResult = Match(inputString, modelPattern)
if matchResult.MatchCount() > 0 then
model = matchResult.GetMatch(1)
end if

matchResult = Match(inputString, vinPattern)
if matchResult.MatchCount() > 0 then
vin = matchResult.GetMatch(1)
vin = Replace(vin, 'VIN ', '') // Remove the 'VIN ' prefix
end if

matchResult = Match(inputString, licensePattern)
if matchResult.MatchCount() > 0 then
license = matchResult.GetMatch(1)
license = Replace(license, 'license ', '') // Remove the 'license ' prefix
end if

// Output the parsed values
MessageBox('Parsed Values', 'Year: ' + year + '~nColor: ' + color + '~nMake: ' + make + '~nModel: ' + model + '~nVIN: ' + vin + '~nLicense: ' + license)

 

In another example, I asked it for code to parse an IMEI number from a mobile phone. It independently recognised the various elements of the phone's IMEI, ie TAC, SNR and CD, and that the IMIE length is 15 digits.  

 

// Function to parse IMEI number

// Returns the parsed IMEI information as a string

string parseIMEINumber(string imeiNumber) {

    string parsedInfo = ""

 

    // Check if IMEI number is valid

    if (Len(imeiNumber) <> 15) then

        return "Invalid IMEI number"

    end if

 

    // Extract information from IMEI number

    string tac = Mid(imeiNumber, 1, 8)

    string snr = Mid(imeiNumber, 9, 6)

    string cd = Mid(imeiNumber, 15, 1)

 

    // Build parsed information string

    parsedInfo += "TAC: " + tac + "~r~n"

    parsedInfo += "SNR: " + snr + "~r~n"

    parsedInfo += "CD: " + cd

 

    return parsedInfo

}

 

// Usage example

string imeiNumber = "123456789012345"

string parsedIMEI = parseIMEINumber(imeiNumber)

 

// Display parsed IMEI information

MessageBox("Parsed IMEI", parsedIMEI)

 

Comment
  1. Arnd Schmidt
  2. Friday, 12 May 2023 09:23 AM UTC
Hi William,



now I understand better what and how you have used it. Thanks for your examples on this topic!



For real life "micro" problems like regular expressions or simple validation that sounds ok, or at least might give some useful hints.

But be careful if the code solution is really PowerScript.

As long as someone is not the person that wants or likes to read manuals or discussions with a some overhead, it makes sense.

It's hard to say if you are really faster with the AI as an advisor instead of reading the documentation/manuals (rtfm) or just inspect/study existing Powerbuilder blogs or open source code from good sources or even to ask some question here.

But I doubt that the AI already offers to generate a simple runnable application or just a couple of userobjects that do some magic.



Cheers and "Keep on coding"

Arnd



  1. Helpful 2
There are no comments made yet.
John Raghanti Accepted Answer Pending Moderation
  1. Thursday, 11 May 2023 12:01 PM UTC
  2. PowerBuilder
  3. # 7

It must've gotten better with PB code. I tried a couple months back and it couldn't get the syntax quite right. It was very good with C# and Python as I recall. That is a pretty amazing piece of technology. 

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 11 May 2023 17:41 PM UTC
We need a CHATPB version - LOL!
  1. Helpful 1
  1. Berka Frenfert
  2. Tuesday, 16 May 2023 08:19 AM UTC
These are extremely dangerous limitations.

May occasionally generate incorrect information

May occasionally produce harmful instructions or biased content

Limited knowledge of world and events after 2021
  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.