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

Bruce Steers bsteers4 at gmail.com
Wed Mar 22 03:01:42 CET 2023


On Tue, 21 Mar 2023 at 23:15, BB <adamnt42 at gmail.com> wrote:

>
> 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> 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.
>>
>
> 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
>

haha , aah I didn't see that.

well that explains it then i guess.
vb ,,, eeew, Now i feel i need to shower or something :-\

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


More information about the User mailing list