using the "value" command and passing variables

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

using the "value" command and passing variables

Post by makeshyft » Mon Jun 17, 2013 11:43 pm

Hi everyone,

I have just spent a few hours trying to solve this and for the life of me I cannot. In my main stack I have a function called "UMP_HEXDigest"

it converts 20 bit sha1digest values to a normal string.

It works fine on its own.

But to when I try to envoke the function from elsewhere using the VALUE command, it just don't play nice. Its not allowing me to use a variablename as a parameter for the function. When it works, it returns the LITERAL value of the variable name and not the content of the variable. I've played with the syntax and I can't seem to get it.

Seems to me that is a limitation of the VALUE command.

PS ... I am taking "it" from ask password, putting it into a variable and then trying to hash it using the function.

Is there a workaround for this?
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: using the "value" command and passing variables

Post by FourthWorld » Mon Jun 17, 2013 11:54 pm

The "value" function is a tricky beast, similar to JavaScript's "eval" in that it attempts to evaluate the expression passed into it. Since the data returned from sha1Digest is binary, it may just be that "value" is tripping up trying to figure out how it's a LiveCode expression.

For hash output as hex, try the binaryDecode function:

Code: Select all

function CleanHash pString
   local tHex
   get binaryDecode("h*", sha1digest(pString), tHex)
   return tHex
end CleanHash
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: using the "value" command and passing variables

Post by makeshyft » Tue Jun 18, 2013 12:01 am

ahhh shikes..... that makes perfect sense.....why convert it if I can just output the proper string to begin with.

Richard.... I can't tell you how much I appreciate all the times you have helped me already and its only been 2 months since I've been here. You are building up some good karma my friend.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: using the "value" command and passing variables

Post by FourthWorld » Tue Jun 18, 2013 12:51 am

I'm just paying it forward, Tom. All these years I've been the lucky recipient of many people's patient assistance. Passing some of that along is the least I can do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply