[Gambas-user] chat.openai.com and gambas3

Bruce Steers bsteers4 at gmail.com
Tue Mar 21 23:56:40 CET 2023


On Tue, 21 Mar 2023, 22:12 Charlie Reinl, <Karl.Reinl at fen-net.de> wrote:

> I asked -> Q:
>
> fill an array with the files of a directory with gambas3
>
> This is the answer from chat.openai.com -> A:
>
> To fill an array with the files of a directory in Gambas 3, you can use
> the "Dir()" function. This function returns a list of all files and
> directories in the specified path.
>
> Here is an example code that fills an array with the files in a
> directory:
>
> [code]
> vbnet
>
> Public Sub FillArrayWithFiles(directory As String)
>   Dim files[] As String
>   Dim filename As String
>
>   files = Dir(directory & "/*")
>
>   For Each filename In files
>     If Not Is_Directory(directory & "/" & filename) Then
>       ' add filename to array
>       Array.Append(files, filename)
>     Endif
>   Next
> End
> [/code]
>
> This code creates an empty array "files[]" and fills it with all file
> names in the specified directory. If the path does not exist or is not
> a directory, an empty array is returned.
>
> Note: Note that "Is_Directory()" is another Gambas function that checks
> whether the path is a directory. You can avoid using this function by
> using "Dir()" with the "DIRECTORY" option, which only returns
> directories.
> <<
> ChatGPT Mar 14 Version. Free Research Preview. Our goal is to make AI
> systems more natural and safe to interact with. Your feedback will help
> us improve.
> >>
>
> Not usable!
> --
> Amicalement
> Charlie.


So teach it better.

That's how it works.

😎

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230321/1f27d0ec/attachment.htm>


More information about the User mailing list