Derek Johnson Active Member Licensed User Longtime User Jan 12, 2023 #21 To be fair to Chat-GPT you didn't mention that the units could be in feet in the list of possible input values. It would be interesting to ask it to convert that code to C++ for use with an Arduino. C++ does not allow Strings in Case statements.
To be fair to Chat-GPT you didn't mention that the units could be in feet in the list of possible input values. It would be interesting to ask it to convert that code to C++ for use with an Arduino. C++ does not allow Strings in Case statements.
Derek Johnson Active Member Licensed User Longtime User Jan 12, 2023 #22 Wow! I just tried your exact same question again. It seems to have learned after its experience with your inputs. In B4A: Using a scale where 16 hammer units is equal to one foot, create a Sub that converts centimeters, millimeters, meters, inches, miles, and yards to feet and convert that value to its value in hammer units. Click to expand... This time the replay included an "Else" case which fixes your original issue. Does that mean that all the feedback improves its answers. [CODE lang="b4x" title="B4A suggested code" highlight="16-17"]Sub ConvertToHammerUnits(value As Double, units As String) Dim feet As Double Select units Case "centimeters" feet = value / 30.48 Case "millimeters" feet = value / 304.8 Case "meters" feet = value / 0.3048 Case "inches" feet = value / 12 Case "miles" feet = value * 5280 Case "yards" feet = value * 3 Case Else feet = value 'assuming input is already in feet End Select Dim hammerUnits As Double = feet * 16 Log("Value in hammer units: " & hammerUnits) End Sub [/CODE] I also asked it to convert the code to C++ which it did flawlessly (as far as I could see).
Wow! I just tried your exact same question again. It seems to have learned after its experience with your inputs. In B4A: Using a scale where 16 hammer units is equal to one foot, create a Sub that converts centimeters, millimeters, meters, inches, miles, and yards to feet and convert that value to its value in hammer units. Click to expand... This time the replay included an "Else" case which fixes your original issue. Does that mean that all the feedback improves its answers. [CODE lang="b4x" title="B4A suggested code" highlight="16-17"]Sub ConvertToHammerUnits(value As Double, units As String) Dim feet As Double Select units Case "centimeters" feet = value / 30.48 Case "millimeters" feet = value / 304.8 Case "meters" feet = value / 0.3048 Case "inches" feet = value / 12 Case "miles" feet = value * 5280 Case "yards" feet = value * 3 Case Else feet = value 'assuming input is already in feet End Select Dim hammerUnits As Double = feet * 16 Log("Value in hammer units: " & hammerUnits) End Sub [/CODE] I also asked it to convert the code to C++ which it did flawlessly (as far as I could see).
AnandGupta Expert Licensed User Longtime User Jan 12, 2023 #23 I am using ChatGPT extensively as 'Codez please' for C# and Sql coding as I develop new app in C# with Sql as database. I have prior knowledge of Xbase++ (Clipper/FoxPro) and DBF/NTX. I am asking simple question to complex ones, and ChatGPT giving me codes for it with explanations, that now I more confident in C# and Sql. ? I only Google for my query, when ChatGPT is not accessible due to heavy load. And there I have to go through number of webpages to get the correct code. ChatGPT does gives wrong code sometimes for C#, as the functions in code is for JS or Java etc., but I get the idea and make changes in the query to get the correct code.
I am using ChatGPT extensively as 'Codez please' for C# and Sql coding as I develop new app in C# with Sql as database. I have prior knowledge of Xbase++ (Clipper/FoxPro) and DBF/NTX. I am asking simple question to complex ones, and ChatGPT giving me codes for it with explanations, that now I more confident in C# and Sql. ? I only Google for my query, when ChatGPT is not accessible due to heavy load. And there I have to go through number of webpages to get the correct code. ChatGPT does gives wrong code sometimes for C#, as the functions in code is for JS or Java etc., but I get the idea and make changes in the query to get the correct code.