aikona
Member
Hi
Small problem ,can't find solution .Inside a VBS script I need to extract the low 16 bits out of a 32 bit integer .In PLC lanquage its easy
L DB1.DBD2 // 32 bit word ie FCA2C4EF
T DB1.DBW6 // 16Bit word becomes C4EF
end of story .But in VBS I can't get it to work .In VBS I extract this 32bit value ... first as a string in a database , I then convert it to a integer and then I try to 'AND' this value with &H0000FFFF but it does not give the required result . The problem is that you cannot 'DIM' a variable as a 16bit INT.
Anybody with a solution ?
the vbs part
tempvar = rst.Fields(0).Value
HMIRuntime.Tags("SQL_LN01_OF_Nr").Write tempvar
intvar2 = CInt(tempvar)
intvar3 = &HFFFF
intvar = intvar2 And intvar3
but I also tried
intvar2 = CInt(tempvar) & &HFFFF
How can you tell a var that it is a 16bit var.
Thanks
Eric
Small problem ,can't find solution .Inside a VBS script I need to extract the low 16 bits out of a 32 bit integer .In PLC lanquage its easy
L DB1.DBD2 // 32 bit word ie FCA2C4EF
T DB1.DBW6 // 16Bit word becomes C4EF
end of story .But in VBS I can't get it to work .In VBS I extract this 32bit value ... first as a string in a database , I then convert it to a integer and then I try to 'AND' this value with &H0000FFFF but it does not give the required result . The problem is that you cannot 'DIM' a variable as a 16bit INT.
Anybody with a solution ?
the vbs part
tempvar = rst.Fields(0).Value
HMIRuntime.Tags("SQL_LN01_OF_Nr").Write tempvar
intvar2 = CInt(tempvar)
intvar3 = &HFFFF
intvar = intvar2 And intvar3
but I also tried
intvar2 = CInt(tempvar) & &HFFFF
How can you tell a var that it is a 16bit var.
Thanks
Eric