Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Friday fun...
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00356714
Message ID:
00356849
Views:
21
A little automation to the process... :)
(Thanks to Mike Helland for his nice mhHTMLcode utility. :)

*************************************************************
* HECK.PRG
* A little wrapper around George Tasker class
* for automatic translation back and forth
*************************************************************
**** Author of this piece: Nick Neklioudov
LPARAMETERS tcText
* You can explicitly pass your text as a parameter, or the program automatically picks
* the clipboard content
IF empty(tcText)
     tcText = ALLTRIM(_CLIPTEXT)
ENDIF
IF empty(tcText)
     RETURN
ELSE && Strip out possible CRLF so the class code doesn't bomb
     tcText = STRTRAN(STRTRAN(tcText,CHR(13)," "),CHR(10),"")
ENDIF
LOCAL loHeck
loHeck = createobject("hexwords")
*Place the result to the clipboard
IF UPPER(LEFT(tcText, 2)) = "0X"
     _CLIPTEXT = loHeck.HexToWord(tcText)
ELSE
     _CLIPTEXT = loHeck.WordToHex(tcText)
ENDIF
* show the result in WAIT WINDOW
WAIT WINDOW _cliptext NOWAIT
RETURN
***** End of Nick's code
***** Author: George Tasker
DEFINE CLASS HexWords AS CUSTOM
     FUNCTION WordToHex
     LPARAMETER tcWord
     LOCAL lni, lnlast, lcresult, lcchar, lnchar
     lcresult = ""
     lnlast = LEN(tcWord)
     FOR lni = 1 TO lnlast
          lcchar = SUBSTR(tcWord, lni, 1)
          lcresult = lcresult + RIGHT(TRANSFORM(ASC(lcchar), "@0"), 2)
     NEXT
     lcresult = "0x" + lcresult
     RETURN lcresult
ENDFUNC
     FUNCTION HexToWord
     LPARAMETER tcHex
     LOCAL lni, lnlast, lcresult, lcHex, lnchar
     lcresult = ""
     lcHex = SUBSTR(tcHex, 3)
     lnlast = LEN(lcHex)
     FOR lni = 1 TO lnlast STEP 2
          lnchar = EVALUATE('0x' + SUBSTR(lcHex, lni, 2))
          lcresult = lcresult + CHR(lnchar)
     NEXT
     RETURN lcresult
ENDFUNC
ENDDEFINE








>Hi Troops,
>
>All the seriousness around here has basically interferred with some of the fun we've had. Friday's especially were fun because it was the end of the week. From verse, to limericks, to puns, to simply being 0x626F6E656865616473, we had some jollies. Then there was this issue of profanity. What we could and couldn't say. Now I'm a pretty light hearted guy, plus I don't believe in censorship. I'm as fun loving the next person. In fact, some call me a 0x6372617A79206D6F74686572206675636B6572. However, I do understand that some folks don't like it and won't tolerate it. So in deference to them...
>
>Now as you might have guessed by this time, the above is a hexidecimal representation of some real words. Are they profane? In one case yes, in the other no. Now, the code below will translate the above into the appropriate words. Now be forewarned, if you don't like profanity, don't use the code to translate it. That's your choice.
>
>So the next time you want to call some one an 0x617373686F6C65, you can use this.:-)
>
>Lastly, I'm sorry, but the above doesn't work with Unicode. It's in the public domain, however, so please feel free to make whatever modifications you like. Just don't come banging on my door if it doesn't work right.:-)
DEFINE CLASS HexWords AS CUSTOM
>
>  FUNCTION WordToHex
>
>    LPARAMETER tcWord
>
>    LOCAL lni, lnlast, lcresult, lcchar, lnchar
>    lcresult = ""
>    lnlast = LEN(tcWord)
>    FOR lni = 1 TO lnlast
>      lcchar = SUBSTR(tcWord, lni, 1)
>      lcresult = lcresult + RIGHT(TRANSFORM(ASC(lcchar), "@0"), 2)
>    NEXT
>    lcresult = "0x" + lcresult
>    RETURN lcresult
>  ENDFUNC
>
>  FUNCTION HexToWord
>
>    LPARAMETER tcHex
>
>    LOCAL lni, lnlast, lcresult, lcHex, lnchar
>    lcresult = ""
>    lcHex = SUBSTR(tcHex, 3)
>    lnlast = LEN(lcHex)
>    FOR lni = 1 TO lnlast STEP 2
>      lnchar = EVALUATE('0x' + SUBSTR(lcHex, lni, 2))
>      lcresult = lcresult + CHR(lnchar)
>    NEXT
>    RETURN lcresult
>  ENDFUNC
>ENDDEFINE
I've gotta stop hanging around with Koziol.< bg >
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform