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

BB adamnt42 at gmail.com
Wed Mar 22 00:13:56 CET 2023


On 22/3/23 9:40 am, Bruce Steers wrote:
>
>
> On Tue, 21 Mar 2023, 22:12 Charlie Reinl, <Karl.Reinl at fen-net.de 
> <mailto: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 <http://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.
>
>
> It only partly right.
> Yes a Dir() function and the read of the array is okay but.
>
> Should be IsDir() not Is_Directory()
> Also Dir takes gb.directory as it's third argument. The second being 
> pattern.
>
> I think it's confused itself with a different language.
>
>
Perhaps that first line in the code is a clue. 😮

b

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230322/fc6fa416/attachment.htm>


More information about the User mailing list