Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII D.O.S. vs Visual

Status
Not open for further replies.

dardapu

Programmer
Sep 10, 2002
67
0
0
I need to coordinate two applications, oen in foxpro 2.6 D.O.S and another in VFP3 (I use this version since I need a small application). The problem is I believe... of platform.
Under D.O.S executes an encriptation routine

.....................................
procedure encryp
parameter value

largo=len(valor)
factor=int(largo*2/3)
encryp =""
for to = 1 long to
letra=substr(valor,a,1)
xvalor=abs(asc(letra)+factor+(a*2)-254)
encryp=encryp+chr(xvalor)
endfor
return encryp

I subtract 254 to always obtain an interval ascii betw 1-254

The problem this in that they are different when reading the table under visual the characters.
I have tried to use the option ANSITOOEM () without success.
Both languages COLLATE=SPANISH are

I will thank all suggestion.

 
I think it is a code page issue.

Use the relevant table in VFP and change the codepage of the table to 437 (which if remember correctly is the codepage for foxdos tables).

You can check the code page of a dbf file using the cpdbf() function. In all probability the code page for the vfp files will be 1252.

**Change code page

use tablename &&the table with codepage to be changed
copy to tablename1 as 437 &&set code page as 437
use tablename1
copy to tablename &&copy back table to original table
erase tablename1.dbf







 
The tablet that contains lauds data to encriptr he has code 850 that is international MSDOS, the same as the base that he will receive the data encripted. To solve the passage I made the following operation.
I open the base origin with visual, I scan the records, encript and I save in the base destination, but I have checked that to the encript a character " nn " assigns him for example the value 128, but when being recorded in the corresponding field it is as a character 44, for that that to the desencript with it formulates it corresponding he gives a negative value as a result generating an error.
I have carried out the test with one it formulates but simple as

procedure encryp
parameter xvalor
largo=len(xvalor)
cad =""
for to = 1 long to
letra=substr(xvalor,a,1)
cad=cad+chr((asc(letra)+a)+5)
endfor
return cad

I have proven with code 437 obtaining the same result

Some advice???
 
dardapu said:
I have tried to use the option ANSITOOEM () without success.
If you have original db in codepage 850 I think you must use OEMTOANSI() instead. Also it´s important where you use it.
Try this:
Code:
procedure encryp  
parameter xvalor  
largo=len(xvalor)  
cad =""  
for to = 1 long to  
    letra=substr(OEMTOANSI(xvalor),a,1)  
    cad=cad+chr((asc(letra)+a)+5)  
endfor  
return cad

Gerardo Czajkowski
ltc.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top