Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Here I go again with my new litle gadget
Message
From
28/09/2011 15:32:39
 
 
To
27/09/2011 17:10:26
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01524685
Message ID:
01525102
Views:
63
>Naoto:
>
>Someone said: "Don't clarify cause it's becomming darker..."
>
>I understand nothing what you wrote but as I am an obedient child I do what the aparatus' user's manual says.
>
>I spent the whole day to find out when the manual says; 0x1b 0x2e in the senddata method shoud be 0x1b+0x2e (without ") and worse. It only works well if I put "chr(27)+chr(n)"
>
>Why if you need chr(27) you put in the manual "0x1b"? Apparently you look more important if you use hexa notation.
>
>If I understand something what you wrote I must expect my nice aparatus will blow up...
>
>If so you might tell me "I told you..."
>
>Thank you.
>
> Héctor

I presume you have little or no experience working with "low level" code* (e.g. machine code/assembly, C). That said, I would strongly advise that you don't try to access the Winsock API directly. Instead you should use the ActiveX control that I'd mentioned previously, you'll be able to avoid "fiddly bits" like memory layout of data structures. I was directly calling API in my own code as I had already been used to writing such code (back in the DOS days you often had to "get to the metal" to get some things done), and at the time when the original code was written in FPW, there was no other alternative. The VFP code was simply an adpatation of the existing code (converted from 16-bit to 32-bit, updated to take advantage of new language features).

With regards to hexadecimal notation. It is rather common to see hexadecimal or octal constants in "low-level" code -- often because it's easier to convert to/from binary -- especially the case when you're working with bitmasks (this is primarily as each. It was also common to see hex constants using the &Hxxx notation (and less frequently octal constants with &Oxxx notation) in BASIC code -- especially when dealing with hardware.

With regards to conversion to and from binary, octal and hexadecimal are easily converted as you simply replace digit with a particular bit pattern. With octal you have groupings of 3 bits, and hex you have groupings of 4 bits. Hex is a bit more popular as it "fits" evenly in 8-bit byte notation (octal seems "weird" as it uses 2-3-3 pattern) on current computers. Octal code is favored on systems that had 6-bit bytes (e.g. Control Data mainframe). Also, you may notice that some microprocessors use bit groupings that are essentially octal when you look at the instruction set (even if they typically use 8-bt bytes).


* low-level and high-level are references to level of abstraction rather than complexity. Low-level typically means you're dealing with more concrete -- in the case of computing, you're specifying things in terms of specific memory location, specific pattern of bits, etc. High-level relates to level of abstraction where you're dealing with the more generic. In terms of human language, low-level would be to point at a specific cow, whereas high level would be to mention "livestock" or "animal" (or at the highest level of abstraction -- "thing").
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform