// \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
// \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
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
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 ?
// ? VAL( CNUM )
cValcNum := VAL( CNUM )
? TRANSF( cValcNum, "99-99-99-99-99-99-99-99-99" )
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
■ 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
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 view
// ? VAL( CNUM )
cValcNum := VAL( CNUM )
? TRANSF( cValcNum, "99-99-99-99-99-99-99-99-99" )
Regards, saludos.
#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
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
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.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 59 guests