Search  
Friday, February 10, 2012 ..:: Forum ::.. Register  Login
 Forum Minimize
Pentru a putea posta mesaje trebuie să vă înregistraţi.
Notă: Mesajele cu conţinut jignitor sau ilegal (inclusiv cereri de soft piratat) nu sunt acceptate şi vor fi şterse imediat .

Pentru a primi raspunsuri rapide si corecte, scrieti in mesaj ce intentionati sa faceti, ce mesaj de eroare primiti, in ce context si in urma caror actiuni. De asemenea, mentionati versiunea de FoxPro in care lucrati!
Dacă nu specificați versiunea, se consideră VFP 9.0 SP2.

SearchForum Home
  Visual FoxPro  Visual FoxPro in general  conversie...
 conversie
 
 8/1/2006 5:59:34 PM
User is offlinegaby
15 posts


conversie
 (Romania) Modified By gaby  on 8/1/2006 9:23:49 PM)
Am o rugaminte foarte mare la voi
Cum se face o transformare din  numeric in litere
Ex.
pentru nota 5,00 sa afisez (cinci)
pentru nota 5,50 sa afisez (cinci, 50%)

Cu multa stima si respect
    Gaby
e-mail: gaby2marian@yahoo.co.uk
 8/1/2006 7:03:57 PM
User is offlinejustalex
126 posts
alexandru360.blogspot.com/
5th




Re: conversie
 (Romania)
io unul nu stiu sa se poata face ce zici tu cu o functie anume

din caracter in numeric se foloseste val() si invers din numeric in caracter functia str() si cam atat legat de siruri dar ce vrei tu nu prea are functii :)

ai putea incerca sa faci un array cu cifre de la cat pana la cat sunt notele sau ce vrei tu
si sa il incarcu cu valori si pt valoarea rezultat scanezi array si ii zici sa-ti intoarca cuvantul aferent cifrei ...

sper sa-ti fi fost de ajutor...
 8/1/2006 8:44:32 PM
User is offlinewtfia
142 posts
5th


Re: conversie
 (N/A)
O procedura veche, care nu e a mea, dar din cate stiu functioneaza. Nu e perfecta, probabil va trebui sa o modifici putin. De ex. ca sa scoti 'LEI'. Poate are altcineva una mai buna.

litere(5.50,'') returneaza CINCI LEI 50%


*****************************
* tranforma numere in litere (1400 = UNAMIEPATRUSUTE LEI)
* primul parametru e numarul care trebuie tranformat

proc litere
para valchi,camt
unitati=" UNA DOUA TREI PATRUCINCISASE SAPTEOPT NOUA "
ones= " UNU DOI TREI PATRUCINCISASE SAPTEOPT NOUA "
spre= "ZECE UNSPREZECE DOISPREZECE TREISPREZECE PATRUSPREZECE"+;
"CINCISPREZECESASESPREZECE SAPTESPRZECE OPTSPREZECE NOUASPREZECE "
zeci= "DOUAZECI TREIZECI PATRUZECICINCIZECISAIZECI SAPTEZECIOPTZECI "+;
"NOUAZECI "
cnum=left(str(valchi,12,2),9)
xx=0
*----------------------------verifica sute milioane----------------------------
if left(cnum,1)>" "
camt=rtri(subs(unitati,val(left(cnum,1))*5+1,5))
if left(cnum,1)="1"
camt=camt+"SUTA"
else
camt=camt+"SUTE"
endi
xx=1
endi
*----------------------------verifica zecile de milioane-----------------------
do case
case subs(cnum,2,1)>"1"
camt=camt+rtri(subs(zeci,val(subs(cnum,2,1))*9-17,9))
if subs(cnum,3,1)>"0"
camt=camt+"SI"+rtri(subs(unitati,val(subs(cnum,3,1))*5+1,5))
endi
camt=camt+"MILIOANE"
case subs(cnum,2,1)="1"
camt=camt+rtri(subs(spre,val(subs(cnum,3,1))*13+1,13))+"MILIOANE"
case subs(cnum,2,2)="00"
camt=camt+"MILIOANE"
case subs(cnum,3,1)>" "
camt=camt+rtri(subs(unitati,val(subs(cnum,3,1))*5+1,5))
if (subs(cnum,3,1))="1".and.xx=0
camt=camt+"MILION"
else
camt=camt+"MILIOANE"
endi
endc
*----------------------------verifica sute mii---------------------------------
if subs(cnum,4,1)>"0"
camt=camt+rtri(subs(unitati,val(subs(cnum,4,1))*5+1,5))
if subs(cnum,4,1)="1"
camt=camt+"SUTA"
else
camt=camt+"SUTE"
endi
endi
*----------------------------verifica zecile de mii----------------------------
do case
case subs(cnum,5,1)>"1"
camt=camt+rtri(subs(zeci,val(subs(cnum,5,1))*9-17,9))
if subs(cnum,6,1)>"0"
camt=camt+"SI"+rtri(subs(unitati,val(subs(cnum,6,1))*5+1,5))
endi
camt=camt+"MII"
case subs(cnum,5,1)="1"
camt=camt+rtri(subs(spre,val(subs(cnum,6,1))*13+1,13))+"MII"
case subs(cnum,5,2)="00".and.subs(cnum,4,1)>"1"
camt=camt+"MII"
case subs(cnum,6,1)>" "
camt=camt+rtri(subs(unitati,val(subs(cnum,6,1))*5+1,5))
if subs(cnum,4,3)#"000"
if (subs(cnum,6,1))="1"
camt=camt+"MIE"
else
camt=camt+"MII"
endi
endi
endc
*----------------------------verifica sutele-----------------------------------
if subs(cnum,7,1)>"0"
camt=camt+rtri(subs(unitati,val(subs(cnum,7,1))*5+1,5))
if subs(cnum,7,1)="1"
camt=camt+"SUTA"
else
camt=camt+"SUTE"
endi
endi
*----------------------------verifica zeci si unitati--------------------------
do case
case subs(cnum,8,1)>"1"
camt=camt+rtri(subs(zeci,val(subs(cnum,8,1))*9-17,9))
if righ(cnum,1)>"0"
camt=camt+"SI"+rtri(subs(ones,val(righ(cnum,1))*5+1,5))
endi
case subs(cnum,8,1)="1"
camt=camt+rtri(subs(spre,val(righ(cnum,1))*13+1,13))
case righ(cnum,2)=" 0"
camt="ZERO"
othe
camt=camt+rtri(subs(ones,val(righ(cnum,1))*5+1,5))
endc
bani=righ(str(valchi,12,2),2)
camt=rtri(camt)+" "+"LEI" && wmony
if bani#'00'
camt=camt+" "+bani+"%"
endi
retu camt
* end procedure litere
********************************
 8/1/2006 11:56:42 PM
User is offlinerlutia66
229 posts
4th




Re: conversie
 (N/A)
FUNCTION NOTA_TO_STR
LPARAMETER MYPARAM && PARAMETRU NOTA
LOCAL CRESULT && VARIABILA LOCALA CARE VA FI REZULTATUL
CRESULT=""

DO CASE
CASE INT(MYPARAM)=1
CRESULT="UNU,"
CASE INT(MYPARAM)=2
CRESULT="DOI,"
CASE INT(MYPARAM)=3
CRESULT="TREI,"
CASE INT(MYPARAM)=4
CRESULT="PATRU,"
CASE INT(MYPARAM)=5
CRESULT="CINCI,"
CASE INT(MYPARAM)=6
CRESULT="SASE,"
CASE INT(MYPARAM)=7
CRESULT="SAPTE,"
CASE INT(MYPARAM)=8
CRESULT="OPT,"
CASE INT(MYPARAM)=9
CRESULT="NOUA,"
CASE INT(MYPARAM)=10
CRESULT="ZECE,"
ENDCASE
MYPARAM=MYPARAM*100 % 100
IF MYPARAM<>0
CRESULT=CRESULT+STR(,MYPARAM,2,0)+"%"
ENDIF

RETURN CRESULT



Sper sa ajute,

Rares LUTIA
Matricia Solutions
 8/2/2006 7:38:15 PM
User is offlinegaby
15 posts


Re: conversie
 (Romania)
Rares
Mersi foarte mult pentru ajutor

Cu respect
Gaby
 8/2/2006 7:39:04 PM
User is offlinegaby
15 posts


Re: conversie
 (Romania)
Rares
Mersi foarte mult pentru ajutor

Cu respect
Gaby
 8/2/2006 7:44:13 PM
User is offlinegaby
15 posts


Re: conversie
 (Romania)
Mersi tuturor pentru ajutor
Gaby
 8/9/2006 7:38:07 PM
User is offlinejustalex
126 posts
alexandru360.blogspot.com/
5th




Re: conversie
 (N/A)
Uite aici tatal lor in materie de conversie procedura luata din cartea 1001 things... de Andy Kramek

Enjoy!

How to convert numbers to words
One common problem is that of converting numbers into character strings, for printing checks,
or as confirmation of an invoice or order total. There have been many solutions proposed for
this over the years, but we still like this one the best because it handles large numbers, negative
numbers and adopts an innovative approach to decimals too.
**********************************************************************
* Program....: NumToStr
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* Abstract...: Convert number into a text string
* Notes......: Handles Numbers up to 99,999,999 and will accommodate
* ...........: negative numbers. Decimals are rounded to Two Places
* ...........: And returned as 'and xxxx hundredths'
************************************************************************
FUNCTION NumToStr
LPARAMETERS tnvalue
LOCAL lnHund, lnThou, lnHTho, lnMill, lnInt, lnDec
LOCAL llDecFlag, llHFlag, llTFlag, llMFlag, llNegFlag
LOCAL lcRetVal
*** Evaluate Parameters
DO CASE
CASE TYPE('tnValue') # 'N'
RETURN('')
CASE tnvalue = 0
RETURN 'Zero'
CASE tnvalue < 0
*** Set the Negative Flag and convert value to positive
llNegFlag = .T.
tnvalue = ABS(tnvalue)
OTHERWISE
llNegFlag = .F.
ENDCASE
*** Initialise Variables
STORE .F. TO llHFlag,llTFlag,llMFlag
STORE 0 TO lnHund, lnThou, lnMill
STORE "" TO lcRetVal
*** Get the Integer portion
lnInt = INT(tnvalue)
*** Check for Decimals
IF MOD( tnValue, 1) # 0
lnDec = ROUND(MOD(tnvalue,1),2)
llDecFlag = .T.
ELSE
llDecFlag = .F.
ENDIF

*** Do the Integer Portion first
DO WHILE .T.
DO CASE
CASE lnInt < 100 && TENS
IF EMPTY(lcRetVal)
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnInt))
ELSE
IF RIGHT(lcRetVal,5)#" and "
lcRetVal = lcRetVal+' and '
ENDIF
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnInt))
ENDIF
CASE lnInt < 1000 && HUNDREDS
lnHund = INT(lnInt/100)
lnInt = lnInt - (lnHund*100)
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnHund)) + " Hundred"
IF lnInt # 0
lcRetVal = lcRetVal+" and "
LOOP
ENDIF
CASE lnInt < 100000 && THOUSANDS
lnThou = INT(lnInt/1000)
lnInt = lnInt - (lnThou*1000)
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnThou)) + " Thousand"
IF lnInt # 0
lcRetVal = lcRetVal + " "
LOOP
ENDIF
CASE lnInt < 1000000 && Hundred Thousands
lnHTho = INT(lnInt/100000)
lnInt = lnInt - (lnHTho * 100000)
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnHTho)) + " Hundred"
IF lnInt # 0
lcRetVal = lcRetVal + " and "
LOOP
ELSE
lcRetVal = lcRetVal + " Thousand"
ENDIF
CASE lnInt < 100000000 && Millions
lnMill = INT(lnInt/1000000)
lnInt = lnInt - (lnMill * 1000000)
lcRetVal = lcRetVal + ALLTRIM(con_tens(lnMill)) + " Million"
IF lnInt # 0
lcRetVal = lcRetVal + ", "
LOOP
ENDIF
ENDCASE
EXIT
ENDDO
*** Now Handle any Decimals
IF llDecFlag
lnDec = lnDec * 100
lcRetVal = lcRetVal + " and " + ALLTRIM(con_tens(lnDec)) + ' Hundredths'
ENDIF
*** Finally Handle the Negative Flag
IF llNegFlag
lcRetVal = "[MINUS " + ALLTRIM(lcRetVal) + "]"
ENDIF
*** Return the finished string

RETURN lcRetVal
***********************************************
*** Handle the TENS conversion
***********************************************
FUNCTION con_tens
LPARAMETERS tndvalue
LOCAL lcStrVal, lcStrTeen
STORE '' TO lcStrVal,lcStrTeen
DO CASE
CASE tnDValue < 20
RETURN(con_teens(tnDValue))
CASE tnDValue < 30
lcStrVal = 'Twenty'
tnDValue = tnDValue - 20
CASE tnDValue < 40
lcStrVal = 'Thirty'
tnDValue = tnDValue - 30
CASE tnDValue < 50
lcStrVal = 'Forty'
tnDValue = tnDValue - 40
CASE tnDValue < 60
lcStrVal = 'Fifty'
tnDValue = tnDValue - 50
CASE tnDValue < 70
lcStrVal = 'Sixty'
tnDValue = tnDValue - 60
CASE tnDValue < 80
lcStrVal = 'Seventy'
tnDValue = tnDValue - 70
CASE tnDValue < 90
lcStrVal = 'Eighty'
tnDValue = tnDValue - 80
CASE tnDValue < 100
lcStrVal = 'Ninety'
tnDValue = tnDValue - 90
ENDCASE
*** Now convert any remaining portion
lcStrTeen = con_teens(tnDValue)
IF LEN(lcStrTeen) # 0
*** Add on the relevant text
lcStrVal = lcStrVal + '-' + lcStrTeen
ENDIF
RETURN TRIM(lcStrVal)
***********************************************
*** Handle the Units/Teens Conversion
***********************************************
FUNCTION con_teens
LPARAMETERS tntvalue
DO CASE
CASE tntvalue = 0
RETURN('')
CASE tntvalue = 1
RETURN('One ')
CASE tntvalue = 2
RETURN('Two ')
CASE tntvalue = 3
RETURN('Three ')
CASE tntvalue = 4
RETURN('Four ')
CASE tntvalue = 5
RETURN('Five ')
CASE tntvalue = 6
RETURN('Six ')
CASE tntvalue = 7
RETURN('Seven ')
CASE tntvalue = 8
RETURN('Eight ')
CASE tntvalue = 9
RETURN('Nine ')
CASE tntvalue = 10
RETURN('Ten ')
CASE tntvalue = 11
RETURN('Eleven ')
CASE tntvalue = 12
RETURN('Twelve ')
CASE tntvalue = 13
RETURN('Thirteen ')
CASE tntvalue = 14
RETURN('Fourteen ')
CASE tntvalue = 15
RETURN('Fifteen ')
CASE tntvalue = 16
RETURN('Sixteen ')
CASE tntvalue = 17
RETURN('Seventeen ')
CASE tntvalue = 18
RETURN('Eighteen ')
CASE tntvalue = 19
RETURN('Nineteen ')
ENDCASE

The design here is interesting in itself. The problem has been tackled by reducing the
various components of a number to a minimum, and the result is a useful function that can be
used as a single line call as follows:
lcOutStr = NumToStr(1372.23) + “ Dollars”
Returns: “One Thousand Three Hundred and Seventy-Two and Twenty-Three
Hundredths Dollars”
 8/10/2006 12:08:20 PM
User is offlineaflorin
838 posts
1st


Re: conversie
 (Romania)
Functia este foarte probabil extrem de utila, doar ca este in engleza. Pentru translarea ei in romana ar mai trebui facute unele ajustari, care sa tina cont de specificul limbii romane (ma refer la chestii gen un/una/o sau doi/doua etc.)
In urma cu ceva timp stiu ca am facut si eu o astfel de functie, pentru un program de generare de OP-uri.

Si am mai vazut si o alta solutie, dar mi se pare cam prea de tot: cineva completase un dbf cu doua coloane: pe prima cifra in N, pe a doua, translarea ei in sir de caractere. Iar cind avea nevoie de ceva, facea un SEEK(). Si mai si populase tabela cu valori pina la un miliard :)

Florin Aparaschivei - Iasi
 8/10/2006 12:18:12 PM
User is offlineGrigore Dolghin
3521 posts
www.class-software.eu
1st






Re: conversie
 (Romania)
Lol!!!! Some people have way too much time....
Grigore Dolghin
Visual FoxPro MVP 2006 - 2010
Class Software
My blog
 8/10/2006 2:12:19 PM
User is offlineDorin Vasilescu
1366 posts
1st




Re: conversie
 (Romania)
Am si eu unul. Scurt de tot fata de ce am mai vazut

* converteste valoare numerica in text pana la 999 miliarde
* val2text(nValoare)
*
LPARAMETERS nVal
LOCAL cText,cTextVal,cNumere, i
LOCAL ARRAY aVal[12]
cText = ''
cTextVal = STR(nVal,15,2)
cNumere='una          doua         trei         patru        cinci        sase         sapte' ;
        + '        opt          noua         zece         unsprezece   doisprezece  treisprezece patrusprezece' ;
        + 'cincisprezecesaisprezece  saptesprezeceoptsprezece  nouasprezece'
aVal = 0

FOR i = 1 to 12
    store VAL(SUBSTR(cTextVal, i ,1)) to aVal[i]
    IF INLIST(i, 11,8,5,2) AND aVal[i] < 2
        aVal[i] = 0
        aVal[i+1] = VAL(SUBSTR(cTextVal, i ,2))
        i = i + 1
    ENDIF
NEXT

cText = IIF( aVal(1) + aVal(2) + aVal(3) = 0 , '' ;
    , IIF( aVal(1)=0 AND aVal(2) = 0 AND aVal[3] = 1 , 'unmiliard' , GenText(aVal(1),aVal(2),aVal(3),cText,cNumere) + 'miliarde'))
cText = IIF( aVal(4) + aVal(5) + aVal(6) = 0 , cText ;
    , IIF( aVal(4)=0 AND aVal(5) = 0 AND aVal[6] = 1 , cText + 'unmilion' , GenText(aVal(4),aVal(5),aVal(6),cText,cNumere)+'milioane'))     
cText = IIF( aVal(7) + aVal(8) + aVal(9) = 0 , cText ;
    , IIF( aVal(7)=0 AND aVal(8) = 0 AND aVal[9] = 1 , cText + 'unamie' , GenText(aVal(7),aVal(8),aVal(9),cText,cNumere)+'mii'))     
cText = GenText(aVal(10),aVal(11),aVal(12),cText,cNumere) + ' lei'

IF SUBSTR(cTextVal,14,2) # '00'
    cText = cText + ' .'+substr(cTextVal,14,2)+' b.'
ENDIF
RETURN  cText

*****************
procedure GenText
para a,b,c,cText,cNumere
IF a>0
    cText =  cText + TRIM(SUBSTR(cNumere,(a-1)*13+1,13))+IIF(a=1,'suta','sute')
ENDIF
if b>1
    cText = cText + TRIM(SUBSTR(cNumere,(b-1)*13+1,13))+'zeci'
endif
if c>0
    if b>0
        cText = cText + 'si'
    endif
    cText = cText + TRIM(SUBSTR(cNumere,(c-1)*13+1,13))
endif
RETURN cText
 8/10/2006 10:32:45 PM
User is offlineDoru Constantin
304 posts
3rd




Re: conversie
 (Romania)
in loc de:
cText = GenText(aVal(10),aVal(11),aVal(12),cText,cNumere) + ' lei'

eu as pune:
cText = GenText(aVal(10),aVal(11),aVal(12),cText,cNumere)
If Right(cText, 3) = "una"
    cText = Left(cText, Len(cText) - 1) + "u"
EndIf
cText = cText + "lei"
 3/17/2008 12:00:40 PM
User is offlinegeaba
20 posts


Re: conversie
 (N/A)

in loc de:

 IF SUBSTR(cTextVal,14,2) # '00'
    cText = cText + ' .'+substr(cTextVal,14,2)+' b.'
ENDIF 

 

am pus:

IF cText = 'unulei'

cText = 'unleu'

ENDIF

IF SUBSTR(cTextVal,14,2) # '00'

cText = cText + 'si '+substr(cTextVal,14,2)+' bani'

ENDIF

sa scrie 'unleu' in loc de 'unulei'

  Visual FoxPro  Visual FoxPro in general  conversie...

Search  Forum Home         

 Google Ads Minimize

    

Copyright 2002-2010 Profox   Terms Of Use  Privacy Statement