Conversion from ca-clipper ( not found a variable)
- Silvio.Falconi
- Posts: 7133
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Conversion from ca-clipper ( not found a variable)
I have this error
Error description: Error BASE/1003 Variabile inesistente: C1
on the source
numeri:= 9
combinaz:= 10
scelta:= "2"
c1:= "102030405060708090"
c2:= "011121314151617181"
c3:= "021222324252627282"
c4:= "031323334353637383"
c5:= "041424344454647484"
c6:= "051525354555657585"
c7:= "061626364656667686"
c8:= "071727374757677787"
c9:= "081828384858687888"
c10:= "091929394959697989"
contacomb:= 1
do while (contacomb <= combinaz)
c:= "C" + LTrim(Str(contacomb))
cnum:= LTrim(Trim(&c)) <----------------- give me error here not found c1
conta:= 1
do while (conta <= Len(cnum) / 2)
num:= "N" + LTrim(Str(conta))
&num:= SubStr(cnum, conta * 2 - 1, 2)
if (SubStr(&num, 1, 1) = "0")
&num:= SubStr(&num, 2, 1)
endif
conta:= conta + 1
enddo
How I can resolve ?
Error description: Error BASE/1003 Variabile inesistente: C1
on the source
numeri:= 9
combinaz:= 10
scelta:= "2"
c1:= "102030405060708090"
c2:= "011121314151617181"
c3:= "021222324252627282"
c4:= "031323334353637383"
c5:= "041424344454647484"
c6:= "051525354555657585"
c7:= "061626364656667686"
c8:= "071727374757677787"
c9:= "081828384858687888"
c10:= "091929394959697989"
contacomb:= 1
do while (contacomb <= combinaz)
c:= "C" + LTrim(Str(contacomb))
cnum:= LTrim(Trim(&c)) <----------------- give me error here not found c1
conta:= 1
do while (conta <= Len(cnum) / 2)
num:= "N" + LTrim(Str(conta))
&num:= SubStr(cnum, conta * 2 - 1, 2)
if (SubStr(&num, 1, 1) = "0")
&num:= SubStr(&num, 2, 1)
endif
conta:= conta + 1
enddo
How I can resolve ?
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
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
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Code: Select all | Expand
// \SAMPLES\SILCONV.PRG - MODIFIED By Joao Santos. 01/03/2022.
// Compilado con: HARBOUR y xHARBOUR. BCC74.
#include "FiveWin.ch"
MEMVAR c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
FUNCTION SILCONV()
LOCAL numeri := 9
LOCAL combinaz := 10
LOCAL scelta := "2"
LOCAL contacomb := 1
LOCAL c, cNum, Conta, Num
c1 := "102030405060708090"
c2 := "011121314151617181"
c3 := "021222324252627282"
c4 := "031323334353637383"
c5 := "041424344454647484"
c6 := "051525354555657585"
c7 := "061626364656667686"
c8 := "071727374757677787"
c9 := "081828384858687888"
c10 := "091929394959697989"
WHILE( contacomb <= combinaz )
SYSREFRESH()
IF contacomb >= combinaz
EXIT
ENDIF
c := "C" + LTrim( Str( contacomb ) )
cnum := LTrim( Trim( &c ) ) // < give me error here not found c1
? cnum // perfecto
conta := 1
WHILE( conta <= Len( cnum ) / 2 )
SYSREFRESH()
num := "N" + LTrim( Str( conta ) )
&num := SubStr( cnum, conta * 2 - 1, 2 )
IF ( SubStr( &num, 1, 1 ) = "0" )
&num := SubStr( &num, 2, 1 )
ENDIF
// No comprendo bien, mas funciona perfecto.
// ? "Line 58/60: ", &num // numeros aleatorios.
conta := conta + 1
ENDDO
contacomb := contacomb + 1 // Incremental number. perfectoÿ
ENDDO
RETURN NIL
// fin / end
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Silvio.Falconi
- Posts: 7133
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Conversion from ca-clipper ( not found a variable)
I not understood, where is the error, on ca-clipper it was ok
the c1,c2... are not memvar but local and each combination have different C(n) there is one have until C45
I not understood why you must change my code allways
the c1,c2... are not memvar but local and each combination have different C(n) there is one have until C45
I not understood why you must change my code allways
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
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
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Silvio, lo que debes entender es que en CLIPPER, HARBOUR o xHARBOUR, siempre tienes varias formas diferentes de hacer lo mismo. El COMPILADOR te permite ser ilimitado. Cada uno tiene su forma de programar, utiliza siempre el modo de programación que más te guste.
Silvio, what you need to understand is that in CLIPPER, HARBOUR or xHARBOUR, you always have several different ways of doing the same thing. The COMPILER allows you to be unlimited. Each one has its way of programming, always use the programming mode that you like the most.
Regards, saludos.
Silvio, what you need to understand is that in CLIPPER, HARBOUR or xHARBOUR, you always have several different ways of doing the same thing. The COMPILER allows you to be unlimited. Each one has its way of programming, always use the programming mode that you like the most.
Code: Select all | Expand
// \SAMPLES\SILCONV2.PRG - MODIFIED By Joao Santos. 02/03/2022.
// Compilado con: HARBOUR y xHARBOUR Para: BCC74.
#include "FiveWin.ch"
FUNCTION SILCONV()
LOCAL numeri := 9
LOCAL combinaz := 10
LOCAL scelta := "2"
LOCAL contacomb := 1
LOCAL c, cNum, Conta, Num
// COMMAND COMBINATION -> Distintas formas de hacer lo mismo.
// Puede comentar con // y el compilador asumirá que las VARIABLES son MEMVAR.
MEMVAR c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
PRIVATE c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
c1 := "102030405060708090"
c2 := "011121314151617181"
c3 := "021222324252627282"
c4 := "031323334353637383"
c5 := "041424344454647484"
c6 := "051525354555657585"
c7 := "061626364656667686"
c8 := "071727374757677787"
c9 := "081828384858687888"
c10 := "091929394959697989"
WHILE( contacomb <= combinaz )
SYSREFRESH()
IF contacomb >= combinaz
EXIT
ENDIF
c := "C" + LTrim( Str( contacomb ) )
cnum := LTrim( Trim( &c ) ) // < give me error here not found c1
? cnum // perfecto
conta := 1
WHILE( conta <= Len( cnum ) / 2 )
SYSREFRESH()
num := "N" + LTrim( Str( conta ) )
&num := SubStr( cnum, conta * 2 - 1, 2 )
IF ( SubStr( &num, 1, 1 ) = "0" )
&num := SubStr( &num, 2, 1 )
ENDIF
// No comprendo bien, mas funciona perfecto.
// ? "Line 60/63: ", &num // numeros aleatorios.
conta := conta + 1
ENDDO
contacomb := contacomb + 1 // Incremental number. perfectoÿ
ENDDO
RETURN NIL
// fin / end
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Silvio.Falconi
- Posts: 7133
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Conversion from ca-clipper ( not found a variable)
Now The function run I insert Memvar but
the experts of fwh / harbor / clipper have always recommended me not to use the memvar and then in the old source of ca-clipper they are local
![Image](https://i.postimg.cc/Wbf9jW57/n.png)
problems:
1) first column I must divide the string into type XX.XX.XX.XX. how I can make ?
2) the other columns are -1 because are not calculate how I can make to show none ?
the experts of fwh / harbor / clipper have always recommended me not to use the memvar and then in the old source of ca-clipper they are local
![Image](https://i.postimg.cc/Wbf9jW57/n.png)
problems:
1) first column I must divide the string into type XX.XX.XX.XX. how I can make ?
2) the other columns are -1 because are not calculate how I can make to show none ?
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
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
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
the experts of fwh / harbor / clipper have always recommended me not to use the memvar and then in the old source of ca-clipper they are local
Esta información es incorrecta. Puede DECLARAR las variables a voluntad.
LOCAL // usar a voluntad
GLOBAL // usar con moderación
MEMVAR // usar a voluntad
PRIVATE // úselo a voluntad, pero no lo use dentro de LOOPINGS, puede explotar la RAM
PÚBLIC // Usar con moderación.
Desafío a cualquier EXPERTO a que demuestre que estoy equivocado. De lo contrario, mi profesor CLIPPER 5.3 va a recibir una paliza. jajajajajajaja.
This information is incorrect. You can DECLARE the variables at will.
LOCAL // use at will
GLOBAL // use sparingly
MEMVAR // use at will
PRIVATE // use it at will, just don't use it inside LOOPINGS, it can explode RAM
PUBLIC // Use sparingly.
I challenge any EXPERT to prove me wrong. Otherwise, my CLIPPER 5.3 teacher is going to take a beating. jajajajajajaja.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
1) first column I must divide the string into type XX.XX.XX.XX. how I can make ?
2) the other columns are -1 because are not calculate how I can make to show none ?
muéstranos un ejemplo práctico de cómo lo estás haciendo, no tengo idea de lo que quieres.
show us a practical example of how you are doing it, i have no idea what you want.
Code: Select all | Expand
// ? VAL( CNUM )
cValcNum := VAL( CNUM )
? TRANSF( cValcNum, "99-99-99-99-99-99-99-99-99" )
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Any variable that is not local must be only used when really necessary (ie. in very rare occasions). The reason is simple: non-local variables break the encapsulation principle so their values are more difficult to trace.
EMG
EMG
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Enrico Maria Giordano wrote:Any variable that is not local must be only used when really necessary (ie. in very rare occasions). The reason is simple: non-local variables break the encapsulation principle so their values are more difficult to trace.
EMG
Master Enrico, I respect your opinion, but I think it has no basis. In which Clipper book or manual did you see this?
Here at this link, you have the Clipper 5.3 manual: Rare exceptions, xHarbour follows the same logic, that's why I like xHarbour better.
https://harbour.github.io/doc/clc53.html#memvar-cmd
I always followed the instructions in manuals and books that adopted the CA-CLIPPER syntax. I've never had problems, I always DECLARE: FIELD, LOCAL, MEMVAR, PRIVATE (I don't use it much) I prefer MEMVAR in Combination with PRIVATE, of course, I don't make excessive use of PRIVATES and PUBLIC, I use it only in exceptional cases. The only one that I'm not used to using, because I don't understand how it works, is GLOBAL.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Master Enrico:
That's how I learned to program in CLIPPER 5.3, and I never had any problems with users, nor a stack overflow or a program breaking, saying that the "VARIABLE DOESN'T EXIST!". A poorly written program is a bad program that sooner or later will generate problems for the user.
Regards, saludos.
That's how I learned to program in CLIPPER 5.3, and I never had any problems with users, nor a stack overflow or a program breaking, saying that the "VARIABLE DOESN'T EXIST!". A poorly written program is a bad program that sooner or later will generate problems for the user.
Code: Select all | Expand
■ This example demonstrates the relationship between a private
and field variable with the same name. The private variable is
declared with the MEMVAR statement:
FUNCTION Example
MEMVAR amount, address
PRIVATE amount := 100
USE Customer NEW
//
? amount // Refers to amount private variable
? Customer->Amount // Refers to Amount field variable
//
RETURN NIL
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Encapsulation is not a concept tied to a particular programming language. It is a good programming principle that is useful to build and maintain a clean project structure. You can learn about it reading any programming theory book.
EMG
EMG
- Silvio.Falconi
- Posts: 7133
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Conversion from ca-clipper ( not found a variable)
karinha wrote:1) first column I must divide the string into type XX.XX.XX.XX. how I can make ?
2) the other columns are -1 because are not calculate how I can make to show none ?
muéstranos un ejemplo práctico de cómo lo estás haciendo, no tengo idea de lo que quieres.
show us a practical example of how you are doing it, i have no idea what you want.Code: Select all | Expand
// ? VAL( CNUM )
cValcNum := VAL( CNUM )
? TRANSF( cValcNum, "99-99-99-99-99-99-99-99-99" )
Regards, saludos.
ahhahaaahahahahahahaahaahhaahahahahaha, you're are Joke
![Smile :)](./images/smilies/icon_smile.gif)
I cannot use your transform TRANSF( cValcNum, "99-99-99-99-99-99-99-99-99" )
![Image](https://i.postimg.cc/DZnC502j/string.png)
But I made a easy function because I not Know the len of the string
Code: Select all | Expand
#include "fivewin.ch"
Function Main ()
? ConvertString("019002894546")
return nil
Function ConvertString(cnum)
local conta:= 1
local cnewstring:=""
do while (conta <= Len(cnum) / 2)
num:= "N" + LTrim(Str(conta))
&num:= SubStr(cnum, conta * 2 - 1, 2)
cnewstring+=&num+"."
conta:= conta + 1
enddo
return cnewstring
only it print the "." also then last number
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
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
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Enrico Maria Giordano wrote:Encapsulation is not a concept tied to a particular programming language. It is a good programming principle that is useful to build and maintain a clean project structure. You can learn about it reading any programming theory book.
EMG
Okay Master Enrico. But what does this have to do with DECLARE the VARIABLES? Can you show something in practice? Are you referring to the creation of classes? Do you NEVER declare variables? As I've never seen a source (.prg) of yours, I can't dispute it. Thanks. Hugs.
Bien maestro Enrico. Pero, ¿qué tiene que ver esto con DECLARAR las VARIABLES? ¿Puedes mostrar algo en la práctica? ¿Te refieres a la creación de clases? ¿NUNCA declaras variables? Como nunca he visto una fuente (.prg) tuya, no puedo discutirlo. Aprender es un placer. Gracias. Abrazos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
I put many samples in this forum during the years, so you should have seen some of my source code. Anyway, maybe you don't know that declaring a variable also defines its scope and lifetime.
A LOCAL variable exists and is only visible inside the function where it is declared.
A STATIC variable declared inside a function is just like a LOCAL one but keeps its value till the end of the program (ie. its lifetime lasts from the declaration to the end of the program).
A STATIC variable declared outside a function is visible in the whole file (the PRG) and its lifetime is like the previous one.
A PRIVATE variable is visible and exists from the declaration to all the functions called by the function where it is declared.
A PUBLIC variable is visible and exists from the declaration to all the program.
So the only variable that fully respect the encapsulation principle is the LOCAL one.
EMG
A LOCAL variable exists and is only visible inside the function where it is declared.
A STATIC variable declared inside a function is just like a LOCAL one but keeps its value till the end of the program (ie. its lifetime lasts from the declaration to the end of the program).
A STATIC variable declared outside a function is visible in the whole file (the PRG) and its lifetime is like the previous one.
A PRIVATE variable is visible and exists from the declaration to all the functions called by the function where it is declared.
A PUBLIC variable is visible and exists from the declaration to all the program.
So the only variable that fully respect the encapsulation principle is the LOCAL one.
EMG
- karinha
- Posts: 7933
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Conversion from ca-clipper ( not found a variable)
Master Enrico Escrebió:
Una variable LOCAL existe y solo es visible dentro de la función donde se declara.
Una variable ESTÁTICA declarada dentro de una función es como una LOCAL pero mantiene su valor hasta el final del programa (es decir, su tiempo de vida dura desde la declaración hasta el final del programa).
Una variable STATIC declarada fuera de una función es visible en todo el archivo (el PRG) y su tiempo de vida es como el anterior.
Una variable PRIVADA es visible y existe desde la declaración hasta todas las funciones llamadas por la función donde se declara.
Una variable PÚBLICA es visible y existe desde la declaración hasta todo el programa.
Entonces, la única variable que respeta completamente el principio de encapsulación es la LOCAL.
Perfect master Enrique, this is how I see the VARIABLE STATEMENTS. And so it is written in the CLIPPER 5.3 books and manuals. Perhaps, I have misunderstood something wrong that you wrote. It doesn't matter, you write your programs his way and I write mine. Thank you for the information. Strong hug..
Perfecto maestro Enrique, así veo yo las DECLARACIONES DE VARIABLES. Y así está escrito en los libros y manuales de CLIPPER 5.3. Tal vez, he entendido mal algo que escribiste mal. No importa, tú escribes tus programas a tu manera y yo escribo el mío. Gracias por la información. Fuerte abrazo.
I will continue to follow my books and manuals. hahahaha
Continuaré siguiendo mis libros y manuales. jajajaja
Regards, saludos.
Una variable LOCAL existe y solo es visible dentro de la función donde se declara.
Una variable ESTÁTICA declarada dentro de una función es como una LOCAL pero mantiene su valor hasta el final del programa (es decir, su tiempo de vida dura desde la declaración hasta el final del programa).
Una variable STATIC declarada fuera de una función es visible en todo el archivo (el PRG) y su tiempo de vida es como el anterior.
Una variable PRIVADA es visible y existe desde la declaración hasta todas las funciones llamadas por la función donde se declara.
Una variable PÚBLICA es visible y existe desde la declaración hasta todo el programa.
Entonces, la única variable que respeta completamente el principio de encapsulación es la LOCAL.
Una variable LOCAL existe y solo es visible dentro de la función donde se declara.
Una variable ESTÁTICA declarada dentro de una función es como una LOCAL pero mantiene su valor hasta el final del programa (es decir, su tiempo de vida dura desde la declaración hasta el final del programa).
Una variable STATIC declarada fuera de una función es visible en todo el archivo (el PRG) y su tiempo de vida es como el anterior.
Una variable PRIVADA es visible y existe desde la declaración hasta todas las funciones llamadas por la función donde se declara.
Una variable PÚBLICA es visible y existe desde la declaración hasta todo el programa.
Entonces, la única variable que respeta completamente el principio de encapsulación es la LOCAL.
Perfect master Enrique, this is how I see the VARIABLE STATEMENTS. And so it is written in the CLIPPER 5.3 books and manuals. Perhaps, I have misunderstood something wrong that you wrote. It doesn't matter, you write your programs his way and I write mine. Thank you for the information. Strong hug..
Perfecto maestro Enrique, así veo yo las DECLARACIONES DE VARIABLES. Y así está escrito en los libros y manuales de CLIPPER 5.3. Tal vez, he entendido mal algo que escribiste mal. No importa, tú escribes tus programas a tu manera y yo escribo el mío. Gracias por la información. Fuerte abrazo.
I will continue to follow my books and manuals. hahahaha
Continuaré siguiendo mis libros y manuales. jajajaja
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341