Hello,
I want to share with a little test that I did with ChatGPT by OpenAI. I asked to the AI to write a function to validate italian VAT numbers and the result was this code:
Code:
FUNCTION ValidateVAT(sVAT)
DECLARE INTEGER nCheck, nSum, nDigit, nControl, i
sVAT = ALLTRIM(sVAT)
IF LEN(sVAT) <> 11 THEN
RETURN 0
END
nCheck = 0
nSum = 0
FOR i = 1 TO 10 DO
nDigit = INT(SUBSTR(sVAT, i, 1))
IF i MOD 2 = 0 THEN
nSum = nSum + nDigit
ELSE
nCheck = nCheck + nDigit
END
END
nControl = (nCheck + nSum * 3) MOD 10
IF nControl <> 0 THEN
nControl = 10 - nControl
END
IF INT(SUBSTR(sVAT, 11, 1)) = nControl THEN
RETURN 1
ELSE
RETURN 0
END
END
then I said to the AI that functions in DataFlex should end with End_Function and Function_Return and the AI corrected the code.
Wow, it's amazing.
by Luca