Author Topic: Improved CustomMem functions EncodeVar & DecodeVar  (Read 3764 times)

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Improved CustomMem functions EncodeVar & DecodeVar
« on: October 03, 2003, 12:25:35 pm »
Okay. Voila! I think I have beat the CustomMem EncodeVar() and DecodeVar() functions into submission. That is to say, I'm submitting new versions here on the forum.

As you may know from my other posts on the subject the original Zabaware EncodeVar() and DecodeVar() functions didn't preserve the data type and returned everything as a string. This is no longer the case.

I've modified the EncodeVar() function to preserve the data type and store it along with the variable. The new DecodeVar() function extracts the original data type info and returns the variable in the original data type format.

No modifications are needed to the usage of EncodeVar() and DecodeVar()  within your code, unless you've added work-arounds to eliminate type mismatch errors. Just substitute the new function definitions for the old ones in the hal4.uhp or hal5.uhp file towards the end. As always, back up your files!

I've done limited testing of the new functions with string, integer, long, single, double and boolean data types. I haven't tested them with dates, currency and a couple other rarely used types. Arrays are not, and can not, be supported in CustomMem.

Give the improved functions a try and post feedback here. As usual I've tried to be careful and accurate in my coding, but I'm only human (not like Hal). Good luck.

= vonsmith =

« Last Edit: October 03, 2003, 12:30:09 pm by vonsmith »
 

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Improved CustomMem functions EncodeVar & DecodeVar
« Reply #1 on: October 03, 2003, 02:48:27 pm »
For some reason I don't see my uploaded text file shown in my prior posting. The forum's attachment dialog window confirmed that it was uploaded, but I don't see a download link within the posting.

Is there something special about uploading a .txt file to the forum that I don't know about? I haven't attached a downloadable file in this forum before. So what's going on?

= vonsmith =

I manually cut and pasted this link:

Attachment link: http://www.zabaware.com/forum/uploaded/vonsmith/2003103143720_EncodeVar,DecodeVar.txt
« Last Edit: October 03, 2003, 02:49:30 pm by vonsmith »
 

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Improved CustomMem functions EncodeVar & DecodeVar
« Reply #2 on: October 04, 2003, 08:39:01 pm »
Very nice. I was planning on compiling my encode and decode functions into Hal's DLL to help out a javascript programmer that wishes to port his program into Hal. Can I have your permission to compile your code into the DLL instead?
Robert Medeksza

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Improved CustomMem functions EncodeVar & DecodeVar
« Reply #3 on: October 06, 2003, 11:20:18 am »
I'm glad this little piece of code will help with Ultra Hal. You certainly have my permission to use the code as you wish.

Attached is the latest version of the code which is a little more optimized. I eliminated the need to remove the "x" spacer and saved about 5 lines of code. The changes do not affect the usage.

= vonsmith =

Attachment link:
http://www.zabaware.com/forum/uploaded/vonsmith/2003106112122_EncodeVar,DecodeVar,v2.txt
« Last Edit: October 06, 2003, 11:21:44 am by vonsmith »