chatGPT writes and executes Harbour code !!!

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Tue Dec 13, 2022 12:43 pm

aCombinaciones[nRow, nCol] = (nIndex - 1) MOD 90 + 1 ?????


How I can modify this ? what mean "MOD" ?

the function generated
Code: Select all  Expand view
FUNCTION Main(nChoice)
  LOCAL aNumbers[90], nSumCyclo, nSumMath, nDistCyclo, nDistMath
  LOCAL nRow, nCol, nIndex
 
  // Inicializar la matriz de n£meros
  FOR nIndex = 1 TO 90
    aNumbers[nIndex] = nIndex
  NEXT
 
  // Mostrar el men£ de opciones
  nChoice = Menu()

  // Combinar los n£meros seg£n la opci¢n seleccionada
  IF nChoice == 1
    nSumCyclo = CombinaSumCyclo(aNumbers)
  ELSEIF nChoice == 2
    nDistCyclo = CombinaDistCyclo(aNumbers)
  ELSEIF nChoice == 3
    nSumMath = CombinaSumMath(aNumbers)
  ELSEIF nChoice == 4
    nDistMath = CombinaDistMath(aNumbers)
  ENDIF

  // Mostrar el resultado en una tabla
  FOR nRow = 1 TO 30
    FOR nCol = 1 TO 3
      IF nChoice == 1
        PRINT aNumbers[nSumCyclo[nRow, nCol]]
      ELSEIF nChoice == 2
        PRINT aNumbers[nDistCyclo[nRow, nCol]]
      ELSEIF nChoice == 3
        PRINT aNumbers[nSumMath[nRow, nCol]]
      ELSEIF nChoice == 4
        PRINT aNumbers[nDistMath[nRow, nCol]]
      ENDIF
    NEXT
    PRINT
  NEXT

  RETURN

/*
FUNCTION Menu()
  LOCAL nChoice

  PRINT "Seleccione una de las siguientes opciones:"
  PRINT "1. Suma ciclometrica"
  PRINT "2. Distancia ciclom‚trica"
  PRINT "3. Suma matem tica"
  PRINT "4. Distancia matem tica"
  PRINT
  INPUT "Opci¢n: ", nChoice

  RETURN nChoice
*/


FUNCTION CombinaSumCyclo(aNumbers)
  LOCAL aCombinaciones[30, 3], nIndex, nRow, nCol

  // Combinar los n£meros seg£n la suma ciclom‚trica
  FOR nRow = 1 TO 30
    FOR nCol = 1 TO 3
      nIndex = (nRow - 1) * 3 + nCol
      aCombinaciones[nRow, nCol] = (nIndex - 1) MOD 90 + 1
    NEXT
  NEXT

  RETURN aCombinaciones

FUNCTION CombinaDistCyclo(aNumbers)
  LOCAL aCombinaciones[30, 3], nIndex, nRow, nCol

  // Combinar los n£meros seg£n la distancia ciclom‚trica
  FOR nRow = 1 TO 30
    FOR nCol = 1 TO 3
      nIndex = (nRow - 1) * 3 + nCol
      aCombinaciones[nRow, nCol] = (nIndex - 1) MOD 90 + 1
    NEXT
  NEXT

  RETURN aCombinaciones

FUNCTION CombinaSumMath(aNumbers)
  LOCAL aCombinaciones[30, 3], nIndex, nRow, nCol

  // Combinar los n£meros seg£n la suma matem tica
  FOR nRow = 1 TO 30
    FOR nCol = 1 TO 3
      nIndex = (nRow - 1) * 3 + nCol
      aCombinaciones[nRow, nCol] = (nIndex - 1) MOD 90 + 1
    NEXT
  NEXT

  RETURN aCombinaciones

FUNCTION CombinaDistMath(aNumbers)
  LOCAL aCombinaciones[30, 3], nIndex, nRow, nCol

  // Combinar los n£meros seg£n la distancia matem tica
  FOR nRow = 1 TO 30
    FOR nCol = 1 TO 3
      nIndex = (nRow - 1) * 3 + nCol
      aCombinaciones[nRow, nCol] = (nIndex - 1) MOD 90 + 1
    NEXT
  NEXT

  RETURN aCombinaciones

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Tue Dec 13, 2022 2:10 pm

Dear Silvio,

If you want to become more impressed, ask chatGPT to provide you the result of the code it gives you :-)

In Harbour, if I remember properly, you use % for MOD

? 5 % 2
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Wed Dec 14, 2022 8:11 am

Antonio,
I made many tries but none run ok
I ask

Can you show me the code of a program written in Harbour language which creates an array of numbers from 1 to 90, without repetition, in an array formed by three numbers, which respect 4 possibilities i.e. the cyclometric sum, the cyclometric distance, the mathematical sum and the mathematical distance and that the user can select one of the 4 possibilities and the value of the sum or of the distance?


result
Code: Select all  Expand view
Here is an example of a program written in Harbour language which creates an array of numbers from 1 to 90, without repetition, in an array formed by three numbers, which respect 4 possibilities i.e. the cyclometric sum, the cyclometric distance, the mathematical sum and the mathematical distance and that the user can select one of the 4 possibilities and the value of the sum or of the distance:

FUNCTION Main()
  LOCAL aArray[90], nSum, nDistance, nChoice
 
  // Initialize the array
  FOR i := 1 TO 90
    aArray[i] := i
  NEXT
 
  // Ask the user to select one of the 4 possibilities
  nChoice := InputBox("Please select one of the 4 possibilities:
  1. Cyclometric Sum
  2. Cyclometric Distance
  3. Mathematical Sum
  4. Mathematical Distance"
)
 
  // Ask the user to enter the sum or distance value
  IF nChoice = 1 OR nChoice = 3
    nSum := InputBox("Please enter the sum value:")
  ELSE
    nDistance := InputBox("Please enter the distance value:")
  ENDIF
 
  // Generate the array
  GenerateArray(aArray, nSum, nDistance, nChoice)
 
  // Print the array
  FOR i := 1 TO 90
    ? aArray[i]
  NEXT
 
  RETURN NIL

FUNCTION GenerateArray(aArray, nSum, nDistance, nChoice)
  LOCAL nIndex, nTemp, nFirst, nSecond, nThird
 
  // Generate the array
  FOR nIndex := 1 TO 90
    nTemp := aArray[nIndex]
   
    // Calculate the sum or distance
    IF nChoice = 1
      nFirst := nTemp
      nSecond := nSum - nFirst
      nThird := nSum - nSecond
    ELSEIF nChoice = 2
      nFirst := nTemp
      nSecond := nFirst + nDistance
      nThird := nSecond + nDistance
    ELSEIF nChoice = 3
      nFirst := nTemp
      nSecond := nSum - nFirst
      nThird := nSum - nSecond
    ELSE
      nFirst := nTemp
      nSecond := nFirst + nDistance
      nThird := nSecond + nDistance
    ENDIF
   
    // Check if the numbers are valid
    IF nFirst > 0 AND nFirst <= 90 AND nSecond > 0 AND nSecond <= 90 AND nThird > 0 AND nThird <= 90
      // Check if the numbers are unique
      IF nFirst <> nSecond AND nSecond <> nThird AND nThird <> nFirst
        // Add the numbers to the array
        aArray[nIndex] := nFirst
        aArray[nIndex + 1] := nSecond
        aArray[nIndex + 2] := nThird
        nIndex := nIndex + 2
      ENDIF
    ENDIF
  NEXT
 
  RETURN NIL


I 'm trying to convert it into a fwh prg
Code: Select all  Expand view
//Here is an example of a program written in Harbour language which creates an array of numbers from 1 to 90, without repetition, in an array formed by three numbers, which respect 4 possibilities i.e. the cyclometric sum, the cyclometric distance, the mathematical sum and the mathematical distance and that the user can select one of the 4 possibilities and the value of the sum or of the distance:

#include "fivewin.ch"

Function Main()
Test(1,6)
return nil


FUNCTION Test(nType,nValue)
  LOCAL aArray[90], nSum, nDistance, nChoice
 
  // Initialize the array
  FOR i := 1 TO 90
    aArray[i] := i
  NEXT
 
  // Ask the user to select one of the 4 possibilities
  nChoice := nType                    //InputBox("Please select one of the 4 possibilities:
 
/*
  1. Cyclometric Sum
  2. Cyclometric Distance
  3. Mathematical Sum
  4. Mathematical Distance") */



  // Ask the user to enter the sum or distance value
  IF nChoice = 1 .OR. nChoice = 3
    nSum :=  nValue    //InputBox("Please enter the sum value:")
  ELSE
    nDistance :=   nValue    //InputBox("Please enter the distance value:")
  ENDIF
 
  // Generate the array
  GenerateArray(@aArray, nSum, nDistance, nChoice)

  xbrowser aArray
 
  // Print the array
*  FOR i := 1 TO 90
 *   ? aArray[i]
 * NEXT
 
  RETURN NIL

FUNCTION GenerateArray(aArray, nSum, nDistance, nChoice)
  LOCAL nIndex, nTemp, nFirst, nSecond, nThird
 
  // Generate the array
  FOR nIndex := 1 TO 90
    nTemp := aArray[nIndex]
   
    // Calculate the sum or distance
    IF nChoice = 1
      nFirst := nTemp
      nSecond := nSum - nFirst
      nThird := nSum - nSecond
    ELSEIF nChoice = 2
      nFirst := nTemp
      nSecond := nFirst + nDistance
      nThird := nSecond + nDistance
    ELSEIF nChoice = 3
      nFirst := nTemp
      nSecond := nSum - nFirst
      nThird := nSum - nSecond
    ELSE
      nFirst := nTemp
      nSecond := nFirst + nDistance
      nThird := nSecond + nDistance
    ENDIF

    // Check if the numbers are valid
    IF nFirst > 0 .AND. nFirst <= 90 .AND. nSecond > 0 .AND. nSecond <= 90 ;
       .AND. nThird > 0 .AND. nThird <= 90

      // Check if the numbers are unique
      IF nFirst <> nSecond .AND. nSecond <> nThird .AND. nThird <> nFirst
        // Add the numbers to the array
        aArray[nIndex] := nFirst
        aArray[nIndex + 1] := nSecond
        aArray[nIndex + 2] := nThird
        nIndex := nIndex + 2
      ENDIF
    ENDIF
  NEXT

  RETURN NIl
 


I try it but not run
It generate an array with 90 number but it not is that I asked
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Wed Dec 14, 2022 8:28 am

Dear Silvio,

You can tell chatGPT about its mistakes in its code and it will fix the mistakes

Just let it know that it is failing and why if possible
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Wed Dec 14, 2022 10:09 am

asked : Can you show me the code of a program written in C++ language to draw a christmas tree in bmp format

SomeOne can try this ? :D :D :D :D

Code: Select all  Expand view
?

#include <iostream>
#include <fstream>
#include <cstdint>

using namespace std;

// Definizione della struttura dell'immagine BMP
struct BMPHeader {
    uint16_t type;
    uint32_t size;
    uint16_t reserved1;
    uint16_t reserved2;
    uint32_t offset;
};

struct BMPInfoHeader {
    uint32_t size;
    int32_t width;
    int32_t height;
    uint16_t planes;
    uint16_t bitCount;
    uint32_t compression;
    uint32_t sizeImage;
    int32_t xPelsPerMeter;
    int32_t yPelsPerMeter;
    uint32_t clrUsed;
    uint32_t clrImportant;
};

// Definizione dei colori
struct Color {
    uint8_t blue;
    uint8_t green;
    uint8_t red;
};

// Funzione per disegnare l'albero di Natale
void drawChristmasTree(Color** image, int width, int height) {
    // Disegna il tronco
    for (int x = width / 2 - 1; x <= width / 2 + 1; x++) {
        for (int y = height - 1; y >= height - 5; y--) {
            image[x][y].red = 0;
            image[x][y].green = 0;
            image[x][y].blue = 0;
        }
    }
    // Disegna la chioma
    for (int x = width / 2 - 5; x <= width / 2 + 5; x++) {
        for (int y = height - 6; y >= height - 10; y--) {
            image[x][y].red = 0;
            image[x][y].green = 255;
            image[x][y].blue = 0;
        }
    }
    // Disegna la stella
    image[width / 2][height - 11].red = 255;
    image[width / 2][height - 11].green = 255;
    image[width / 2][height - 11].blue = 0;
}

int main() {
    // Definizione delle dimensioni dell'immagine
    const int width = 16;
    const int height = 16;

    // Creazione dell'immagine
    Color** image = new Color*[width];
    for (int i = 0; i < width; i++) {
        image[i] = new Color[height];
    }

    // Disegna l'albero di Natale
    drawChristmasTree(image, width, height);

    // Creazione del file BMP
    ofstream out("christmas_tree.bmp", ios::binary);

    // Scrittura dell'header
    BMPHeader header;
    header.type = 0x4D42;
    header.size = width * height * 3 + 54;
    header.reserved1 = 0;
    header.reserved2 = 0;
    header.offset = 54;
    out.write((char*)&header, sizeof(BMPHeader));

    // Scrittura dell'info header
    BMPInfoHeader infoHeader;
    infoHeader.size = 40;
    infoHeader.width = width;
    infoHeader.height = height;
    infoHeader.planes = 1;
    infoHeader.bitCount = 24;
    infoHeader.compression = 0;
    infoHeader.sizeImage = width * height * 3;
    infoHeader.xPelsPerMeter = 0;
    infoHeader.yPelsPerMeter = 0;
    infoHeader.clrUsed = 0;
    infoHeader.clrImportant = 0;
    out.write((char*)&infoHeader, sizeof(BMPInfoHeader));

    // Scrittura dei dati dell'immagine
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            out.write((char*)&image[x][y], sizeof(Color));
        }
    }

    // Chiusura del file
    out.close();

    // Deallocazione della memoria
    for (int i = 0; i < width; i++) {
        delete[] image[i];
    }
    delete[] image;

    return 0;
}




on fwh
Code: Select all  Expand view
?

//Inizio del codice
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapigt.h"
#include "hbapifs.h"

//Dichiarazione delle variabili
HB_FUNC( DRAWTREE )
{
   //Dichiarazione delle variabili
   int iWidth = hb_parni( 1 );
   int iHeight = hb_parni( 2 );
   int iX = hb_parni( 3 );
   int iY = hb_parni( 4 );
   int iColor = hb_parni( 5 );
   int iStarX = iX + ( iWidth / 2 );
   int iStarY = iY + ( iHeight / 4 );
   int iTrunkX = iX + ( iWidth / 2 );
   int iTrunkY = iY + ( iHeight * 3 / 4 );
   int iTrunkWidth = iWidth / 10;
   int iTrunkHeight = iHeight / 4;
   int iBranchX = iX + ( iWidth / 4 );
   int iBranchY = iY + ( iHeight / 2 );
   int iBranchWidth = iWidth / 2;
   int iBranchHeight = iHeight / 2;
   int iLeafX = iX;
   int iLeafY = iY;
   int iLeafWidth = iWidth;
   int iLeafHeight = iHeight / 2;
   int iStarWidth = iWidth / 10;
   int iStarHeight = iHeight / 10;

   //Creazione dell'immagine
   hb_gtCreateBitmap( iWidth, iHeight, "tree.bmp" );

   //Disegno del tronco
   hb_gtDrawBox( iTrunkX, iTrunkY, iTrunkX + iTrunkWidth, iTrunkY + iTrunkHeight, iColor );

   //Disegno del ramo
   hb_gtDrawBox( iBranchX, iBranchY, iBranchX + iBranchWidth, iBranchY + iBranchHeight, iColor );

   //Disegno delle foglie
   hb_gtDrawBox( iLeafX, iLeafY, iLeafX + iLeafWidth, iLeafY + iLeafHeight, iColor );

   //Disegno della stella
   hb_gtDrawBox( iStarX, iStarY, iStarX + iStarWidth, iStarY + iStarHeight, iColor );

   //Salvataggio dell'immagine
   hb_gtSaveBitmap( "tree.bmp", 0, 0, iWidth, iHeight );
}
//Fine del codice
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Wed Dec 14, 2022 10:36 am

chatGPT is amazing! :-)

https://chat.openai.com/chat
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Wed Dec 14, 2022 10:48 am

Dear Silvio,

For images better use Dall-e https://playgrounds.ai/models/dalle-mini

a lovely christmas tree close to a Harbour where boats can be seen, full of snow and lovely lights in the sunset


https://github.com/FiveTechSoft/screenshots/blob/master/christmas_trees_ai.jpg
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: chatGPT writes and executes Harbour code !!!

Postby Otto » Wed Dec 14, 2022 5:35 pm

Dear friends,

Here you can see how to create a webform with OpenAI.
The IDs are assigned automatically by OpenAI.

We can use the Form with mod harbour and all is working.

https://mybergland.com/fwforum/openui.mp4

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Sun Dec 18, 2022 9:45 pm

Antonio Linares wrote:Dear Silvio,

For images better use Dall-e https://playgrounds.ai/models/dalle-mini

a lovely christmas tree close to a Harbour where boats can be seen, full of snow and lovely lights in the sunset




it was just a request out of frustration because all the functions i requested before don't actually work
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Sun Dec 18, 2022 10:30 pm

Dear Antonio,
I reformulated my questions in chat and this evening it gave me this function
i told him to show me the result and the chat gave me the result i wanted but when i tried the function
I compiled it and it gives me an empty array why ?

this is the test

Code: Select all  Expand view

#include "FiveWin.ch"



Function test()
local aData := createArray()
xbrowser aData
return nil

FUNCTION createArray()      
  LOCAL aData := {}
  FOR i := 1 TO 90
    FOR j := i+1 TO 90
      FOR k := j+1 TO 90
        IF ABS(i - j) = 1 .AND. ABS(j - k) = 1 .AND. ABS(i - k) = 1 //THEN
          aadd(aData, {i, j, k})
        ENDIF
      NEXT
    NEXT
  NEXT
  RETURN aData


 

where is the error ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Mon Dec 19, 2022 7:29 am

Dear Silvio,

Please a MsgInfo() abve the call to AAdd() and check if the condition is working
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Mon Dec 19, 2022 7:20 pm

Antonio Linares wrote:Dear Silvio,

Please a MsgInfo() abve the call to AAdd() and check if the condition is working

I made it
the procedure not working on "If"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Mon Dec 19, 2022 9:19 pm

Antonio Linares wrote:Dear Silvio,

Please a MsgInfo() abve the call to AAdd() and check if the condition is working



Antonio ,
this afternoon I've always been in the chat (https://chat.openai.com/chat) and in the end I managed to find a solution for three out of 2 functions

mathematical sum run ok
Code: Select all  Expand view

FUNCTION somma_matematica(nvalore)  
 local aTmp := {}
 local i,j,k

  FOR i := 1 TO 90
    FOR j := i+1 TO 90
      FOR k := j+1 TO 90
         IF i + j + k == nvalore
           AaDd( aTmp, { i, j, k } )
        ENDIF
      NEXT
    NEXT
  NEXT
  RETURN aTmp


cyclometric sum run ok
Code: Select all  Expand view
FUNCTION somma_ciclometrica(nvalore)
 local aTmp := {}
 local i,j,k
local nTemp
  FOR i := 1 TO 90
    FOR j := i+1 TO 90
      FOR k := j+1 TO 90
           nTemp:=i + j + k
           nTemp := nTemp % 90
         IF nTemp == nvalore
           AaDd( aTmp, { i, j, k } )
        ENDIF
      NEXT
    NEXT
  NEXT
  RETURN aTmp


instead these last two functions do not run well, mathematical distance and cyclometric distance
I couldn't get these functions fixed

mathematical distance
Code: Select all  Expand view
FUNCTION distanza_matematica(nvalore)
 local aTmp := {}
 local i,j,k
 local nTemp

  FOR i := 1 TO 90
    FOR j := i+1 TO 90
       FOR k := j+1 TO 90

         IF ABS(i - j) == nvalore .AND.;
                ABS(j - k) == nvalore .AND.;
                 ABS(i - k) == nvalore
         AaDd( aTmp, { i, j, k } )
        ENDIF
      NEXT
    NEXT
  NEXT
  RETURN aTmp



cyclometric distance

Code: Select all  Expand view


FUNCTION distanza_ciclometrica(nvalore)
   local aTmp := {}
   local i, j, k

   FOR i := 1 TO 90
      FOR j := i+1 TO 90
         FOR k := j+1 TO 90
            nTemp := CalcoloDistanza(i, j, k)
            IF nTemp == nvalore
               AaDd(aTmp, {i, j, k})
            ENDIF
         NEXT
      NEXT
   NEXT
   RETURN aTmp

FUNCTION CalcoloDistanza(n1, n2, n3)
   local  nMin := n1
   local  nMax := n1
   local nTemp

   IF n2 < nMin
      nMin := n2
   ENDIF
   IF n3 < nMin
      nMin := n3
   ENDIF
   IF n2 > nMax
      nMax := n2
   ENDIF
   IF n3 > nMax
      nMax := n3
   ENDIF

   nTemp := (nMax - nMin) % 90

   IF nTemp > 45
      nTemp := 90 - nTemp
   ENDIF

   RETURN nTemp

 


to test the functions just create a small procedure like this

Code: Select all  Expand view
#include "FiveWin.ch"

Function test()
   local aData:= {}

  //run ok
   aData:= somma_matematica(8)
   xbrowser aData   title ltrim(str(len(aData)))
 
   aData:= distanza_matematica(1)
   xbrowser aData  title ltrim(str(len(aData)))
   
  aData:= somma_ciclometrica(1)
  xbrowser aData  title ltrim(str(len(aData)))


   
   aData:= distanza_ciclometrica(1)
   xbrowser aData  title ltrim(str(len(aData)))

return nil



could someone help me please
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Jimmy » Mon Dec 19, 2022 11:33 pm

hi Silvio,

your Function CalcoloDistanza(n1, n2, n3) have 3 x Parameter

Question : are these 3 Parameter point of a Triangle :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Tue Dec 20, 2022 1:07 am

Jimmy wrote:hi Silvio,

your Function CalcoloDistanza(n1, n2, n3) have 3 x Parameter

Question : are these 3 Parameter point of a Triangle :?:


No i must make an Array with 3element
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 24 guests