350.zip

  • PUDN用户
    了解作者
  • VFP
    开发工具
  • 1.5MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2011-08-13 10:10
    上传日期
FoxPro 经典问答 350 虽然这个语言用的人不多但我觉得还是很适用的,相信这个文档会帮助须要他的人请不要删除
350.zip
  • FoxPro350
  • $WWKeywordLinks
  • Property
    4B
  • $WWAssociativeLinks
  • Property
    4B
  • a275.htm
    678B
  • a240.htm
    2.4KB
  • a142.htm
    4.9KB
  • a229.htm
    2.8KB
  • a103.htm
    1.4KB
  • a165.htm
    32.5KB
  • a153.htm
    4KB
  • a75.htm
    3.9KB
  • a305.htm
    1.7KB
  • a343.htm
    5.9KB
  • a138.htm
    307B
  • a8.htm
    305B
  • a209.htm
    2.7KB
  • a73.htm
    3.3KB
  • a31.htm
    4.4KB
  • a54.htm
    4.9KB
  • a258.htm
    5.6KB
  • a188.htm
    3.4KB
  • a259.htm
    1.8KB
  • a83.htm
    1.1KB
  • a222.htm
    1.9KB
  • a137.htm
    3.3KB
  • a90.htm
    4.3KB
  • a310.htm
    2.1KB
  • a7.htm
    25KB
  • a102.htm
    1.8KB
  • a246.htm
    309B
  • a236.htm
    302B
  • a164.htm
    3KB
  • a226.htm
    2.3KB
  • a123.htm
    5KB
  • a12.htm
    8.8KB
  • a40.htm
    2.5KB
  • a215.htm
    8.9KB
  • a286.htm
    1.1KB
  • a150.htm
    8.2KB
  • a178.htm
    11.9KB
  • a276.htm
    463B
  • a6.htm
    9.1KB
  • a336.htm
    3.4KB
  • #URLTBL
    4.2KB
  • a17.htm
    16.9KB
  • a237.htm
    1KB
  • a118.htm
    3.8KB
  • #IDXHDR
    4KB
  • a211.htm
    512B
  • a193.htm
    660B
  • a195.htm
    3.8KB
  • a152.htm
    3.2KB
  • a99.htm
    20KB
  • a68.htm
    318B
  • a159.htm
    289B
  • a88.htm
    2KB
  • a122.htm
    10.8KB
  • a168.htm
    4KB
  • a55.htm
    3.2KB
  • a129.htm
    2.2KB
  • a141.htm
    4.6KB
  • a38.htm
    2.1KB
  • a143.htm
    13.7KB
  • a149.htm
    1.3KB
  • a260.htm
    1.4KB
  • a202.htm
    5.9KB
  • $OBJINST
    2.7KB
  • a265.htm
    4.7KB
  • a272.htm
    3.5KB
  • a238.htm
    2.9KB
  • a166.htm
    1.4KB
  • a107.htm
    10KB
  • a298.htm
    2KB
  • a106.htm
    7.6KB
  • a207.htm
    6.7KB
  • a87.htm
    1.5KB
  • a301.htm
    4.9KB
  • a248.htm
    1.5KB
  • a130.htm
    5KB
  • a79.htm
    2.5KB
  • a334.htm
    11.1KB
  • a127.htm
    1.9KB
  • a194.htm
    1.9KB
  • a290.htm
    1.9KB
  • a114.htm
    3.5KB
  • a241.htm
    1.3KB
  • a232.htm
    1.3KB
  • a34.htm
    5.9KB
  • a218.htm
    985B
  • a89.htm
    2KB
  • a21.htm
    3KB
  • a49.htm
    3.2KB
  • a85.htm
    13.7KB
  • a50.htm
    944B
  • a173.htm
    8.5KB
  • a20.htm
    1.5KB
  • a329.htm
    2.1KB
  • a154.htm
    2.5KB
内容介绍
<html><head><meta http-equiv=Content-Type content=text/html; charset=gb2312><title>g. 二/八/十/十六进制转换函数</title></head><body bgcolor=#F4ECDB><p align="center"><b><font size="5" color="#0000FF">g. 二/八/十/十六进制转换函数</font></b><p align="center"><font color="#FF0000">夜来香</font></p>Conversion Functions: Dec,Hex,Binary,Oct Back and Forth &nbsp;&nbsp;&nbsp;&nbsp;Here are a few conversion functions. Some of which have already been convered in threads, but I thought I would put them in an FAQ for easier reference. <br>&nbsp;&nbsp;&nbsp;&nbsp;1 Hex>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert Hexadecimal values to Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp;2 Decimal>Hex<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert Decimal values to Hexadecimal <br>&nbsp;&nbsp;&nbsp;&nbsp;3 So. What if we need bigger? Different base?<br>&nbsp;&nbsp;&nbsp;&nbsp;4 Dec2BasX <br>&nbsp;&nbsp;&nbsp;&nbsp; Convert Decimal values to any base from binary to hex (216)<br>&nbsp;&nbsp;&nbsp;&nbsp;5 Binary>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert 1's and 0's to whole number<br>&nbsp;&nbsp;&nbsp;&nbsp;6 Binary>Hex<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert 1's and 0's to hex number<br>&nbsp;&nbsp;&nbsp;&nbsp;7 Another Hex>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp; For grins, here's a manual hex>dec conversion function<br>&nbsp;&nbsp;&nbsp;&nbsp;8 Float>Binary>BCD<br>&nbsp;&nbsp;&nbsp;&nbsp; Take a float (e.g. 123.45) and convert it to binary string which can then be converted to hex bcd using bin2hex. <br>&nbsp;&nbsp;&nbsp;&nbsp;9 .Decimal>Binary<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert floating point fraction to binary string<br>&nbsp;&nbsp;&nbsp;&nbsp;10 Binary>Hexadecimal<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert binary string to bcd hex in groups of 4<br>&nbsp;&nbsp;&nbsp;&nbsp;11 BCD>Hexidecimal>Binary<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert hex bcd number to binary representation of bcd number <br>&nbsp;&nbsp;&nbsp;&nbsp;12 Binary>Float<br>&nbsp;&nbsp;&nbsp;&nbsp; Converts binary to floating point decimal number, whole portion and fraction.<br>&nbsp;&nbsp;&nbsp;&nbsp;13 Binary>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert binary string to whole number<br>&nbsp;&nbsp;&nbsp;&nbsp;14 Binary>.Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp; Convert binary string to decimal fraction<br>&nbsp;&nbsp;&nbsp;&nbsp;15 Tie 'em together <br>&nbsp;&nbsp;&nbsp;&nbsp; Let's do some converting now<br>&nbsp;&nbsp;&nbsp;&nbsp;16 Complete procedure file CVT.PRG <br>&nbsp;&nbsp;&nbsp;&nbsp; This is a complete listing of the functions with no tutorials, so it should compile error free if you cut and paste to a procedure file.<br>&nbsp;&nbsp;&nbsp;&nbsp;17 Form code to demo conversions <br>&nbsp;&nbsp;&nbsp;&nbsp; This is a demo form. Input a number and hit Enter or click the 'Convert' button. It will do the converting, then convert it back for comparison. Not that you need the aforementioned procedure file laying around so the program can grab it.<br>&nbsp;&nbsp;&nbsp;&nbsp;First, let's look at the built in ones.<br>&nbsp;&nbsp;&nbsp;&nbsp;1 Hex>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp;Natively, VFP can do hex to decimal conversion like this:<br>&nbsp;&nbsp;&nbsp;&nbsp;?0xffff<br>&nbsp;&nbsp;&nbsp;&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;STORE 0xffff TO nVar <br>&nbsp;&nbsp;&nbsp;&nbsp;And so on. The result is an integer value, 65535.<br>&nbsp;&nbsp;&nbsp;&nbsp;2 Decimal>Hex<br>&nbsp;&nbsp;&nbsp;&nbsp;VFP can also convert decimal to hex:<br>&nbsp;&nbsp;&nbsp;&nbsp;?Transform(65535, '@0x')<br>&nbsp;&nbsp;&nbsp;&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;STORE Transform(65535, '@0x') TO cHexStr<br>&nbsp;&nbsp;&nbsp;&nbsp;Notice that the return value is character, but you get a hex representation of 65535 as 0x0000FFFF.<br>&nbsp;&nbsp;&nbsp;&nbsp;Note: The largest hex value that can be returned by this method is 4294967295, or 0xFFFFFFFF<br>&nbsp;&nbsp;&nbsp;&nbsp;3 So. What if we need bigger? Different base?<br>&nbsp;&nbsp;&nbsp;&nbsp;Following are a couple functions I wrote for previous apps. One function that will take a whole number in the range of 09007199254740992 and convert it to any base, as long as it is base 2 to 16. That includes binary, octal, or any useless base in between. <br>&nbsp;&nbsp;&nbsp;&nbsp;The biggest number it can handle is 9007199254740992, as VFP docs point out, that is the biggest number VFP can handle.<br>&nbsp;&nbsp;&nbsp;&nbsp;4 Dec2BasX <br>&nbsp;&nbsp;&nbsp;&nbsp;*..............................................................................<br>&nbsp;&nbsp;&nbsp;&nbsp;* Function: DEC2BASX<br>&nbsp;&nbsp;&nbsp;&nbsp;* Purpose: Convert whole number 0?, to base 216 <br>&nbsp;&nbsp;&nbsp;&nbsp;*<br>&nbsp;&nbsp;&nbsp;&nbsp;* Parameters: nTempNum number to convert (09007199254740992)<br>&nbsp;&nbsp;&nbsp;&nbsp;* base base to convert to i.e., 2 4 8 16...<br>&nbsp;&nbsp;&nbsp;&nbsp;* returns: string<br>&nbsp;&nbsp;&nbsp;&nbsp;* Usage: cresult=Dec2BasX(nParm1, nParm2)<br>&nbsp;&nbsp;&nbsp;&nbsp;* STORE Dec2BasX(255, 16) TO cMyString &&... cMyString contains 'ff'<br>&nbsp;&nbsp;&nbsp;&nbsp;*..............................................................................<br>&nbsp;&nbsp;&nbsp;&nbsp;FUNCTION dec2basx<br>&nbsp;&nbsp;&nbsp;&nbsp;PARAMETERS nTempNum, nNewBase<br>&nbsp;&nbsp;&nbsp;&nbsp;STORE 0 TO nWorkVal,;<br>&nbsp;&nbsp;&nbsp;&nbsp; remainder,;<br>&nbsp;&nbsp;&nbsp;&nbsp; dividend,;<br>&nbsp;&nbsp;&nbsp;&nbsp; nextnum,;<br>&nbsp;&nbsp;&nbsp;&nbsp; digit<br>&nbsp;&nbsp;&nbsp;&nbsp;nWorkVal = nTempNum <br>&nbsp;&nbsp;&nbsp;&nbsp;ret_str = ''<br>&nbsp;&nbsp;&nbsp;&nbsp;DO WHILE .T.<br>&nbsp;&nbsp;&nbsp;&nbsp; digit = MOD(nWorkVal, nNewBase)<br>&nbsp;&nbsp;&nbsp;&nbsp; dividend = nWorkVal / nNewBase<br>&nbsp;&nbsp;&nbsp;&nbsp; nWorkVal = INT(dividend)<br>&nbsp;&nbsp;&nbsp;&nbsp; DO CASE<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 10<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'a' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 11<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'b' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 12<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'c' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 13<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'd' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 14<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'e' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; CASE digit = 15<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = 'f' + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; OTHERWISE<br>&nbsp;&nbsp;&nbsp;&nbsp; ret_str = LTRIM(STR(digit)) + ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp; ENDCASE<br>&nbsp;&nbsp;&nbsp;&nbsp; IF nWorkVal = 0<br>&nbsp;&nbsp;&nbsp;&nbsp; EXIT<br>&nbsp;&nbsp;&nbsp;&nbsp; ENDIF ( nWorkVal = 0 )<br>&nbsp;&nbsp;&nbsp;&nbsp;ENDDO ( .T. )<br>&nbsp;&nbsp;&nbsp;&nbsp;RETURN ret_str<br>&nbsp;&nbsp;&nbsp;&nbsp;*: eof dec2basx<br>&nbsp;&nbsp;&nbsp;&nbsp;5 Binary>Decimal<br>&nbsp;&nbsp;&nbsp;&nbsp;Now, we want to convert binary to decimal. This function will take a binary string between '0' and <br>&nbsp;&nbsp;&nbsp;&nbsp;'11111111111111111111111111111111111111111111111111111' <br>&nbsp;&nbsp;&nbsp;&nbsp;(53 1's, or 9007199254740991) and convert it to decimal. <br>&nbsp;&nbsp;&nbsp;&nbsp;*..................................................................<br>&nbsp;&nbsp;&nbsp;&nbsp;* Function: bin2dec<br>&nbsp;&nbsp;&nbsp;&nbsp;* Purpose: convert binary string to decimal number<br>&nbsp;&nbsp;&nbsp;&nbsp;* Parameters: pbinnum string to convert i.e.,<br>&nbsp;&nbsp;&nbsp;&nbsp;* '0' '11111111111111111111111111111111111111111111111111111' <br>&nbsp;&nbsp;&nbsp;&nbsp;* '0' (53 1's)<br>&nbsp;&nbsp;&nbsp;&nbsp;* returns: integer data type<br>&nbsp;&nbsp;&nbsp;&nbsp;* Usage: nresult = Bin2Dec(cParm1)<br>&nbsp;&nbsp;&nbsp;&nbsp;* STORE Bin2Dec('11111111') TO nMyNum &&... nMyNum contains 255 <br>&nbsp;&nbsp;&nbsp;&nbsp;*
评论
    相关推荐
    • foxpro二维码
      FoxBarcodeQR is a application free software and offers a barcode tool for the Visual FoxPro Community. This is a supplement of FoxBarcode class only for QR Code barcodes. FoxBarcodeQR use the free ...
    • visual foxpro
      visual foxpro常用的数据库软件,占用资源小,容易上手
    • Visual foxpro 6.0
      Visual foxpro 6.0 在学校学数据库的学生大多数都在学习的,
    • FOXPRO 数据库修复
      FOXPRO 数据库损坏时,可以尝试用它来修复。大家知道FOX数据库比较容易坏,这个可以派上用场。
    • Visual Foxpro 9
      微软Visual Foxpro 9 SP2版本,foxpro是一款经典的桌面数据库产品,虽然目前电子表格有Excel, 桌面数据库有Access,但是Excel对SQL的支持等方面不及foxpro,Access的人机命令交互等方面不如Foxpro
    • Visual FoxPro
      Visual FoxPro,一种数据库,学习课件
    • foxpro API
      Visual foxpro API 讓您使用在windows 相關命令
    • FOXPRO FOR WINXP
      FOXPRO FOR WINXP 好用的数据库 FOXPRO FOR WINXP 好用的数据库 FOXPRO FOR WINXP 好用的数据库 FOXPRO FOR WINXP 好用的数据库 FOXPRO FOR WINXP 好用的数据库 FOXPRO FOR WINXP 好用的数据库
    • Microsoft Visual FoxPro 6.0
      visual foxpro简称VFP,同VB、DELPHI一样都是程序开发工具,VFP由于自带免费的DBF格式的数据库,在国内曾经是非常流行的开发语言,现在许多单位的MIS系统都是用VFP开发的。VFP主要用在小规模企业单位的MIS系统开发,...
    • Visual FoxPro 9.0
      Visual FoxPro 9.0运行库 简体中文版 软件大小 3.75 MB 软件类别 [数据库相关 → 桌面数据库] 授权方式 免费版 最后更新 2006-12-9 [by User2] 推荐等级 相关链接 http://www.Microsoft.com/ 运行环境 Win9x,...