how to check whether setkey was successful ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

how to check whether setkey was successful ?

Post by autocart »

obviously setkey is a SC command and has no return value.
Of course I can check with getkey to see if the value is the one desired.
but of course, this takes unreasonable time since the file needs to be accessed again.
would it not be better if setkey was a function and had a return value indicating whether it was successful or not?

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: how to check whether setkey was successful ?

Post by PeterH »

I think we had this type of problem long long ago, maybe not in exact the same context.

My current idea for this would be if XY defined a variable like <rc>, containing return code information for the last executed command or function. (This way it also could be used for functions usually returning other information.)

admin
Site Admin
Posts: 66678
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how to check whether setkey was successful ?

Post by admin »

PeterH wrote:I think we had this type of problem long long ago, maybe not in exact the same context.

My current idea for this would be if XY defined a variable like <rc>, containing return code information for the last executed command or function. (This way it also could be used for functions usually returning other information.)
Good idea, but cannot be done. It would be an incredible amount of work to implement and document it.

autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

Re: how to check whether setkey was successful ?

Post by autocart »

admin wrote:
PeterH wrote:I think we had this type of problem long long ago, maybe not in exact the same context.

My current idea for this would be if XY defined a variable like <rc>, containing return code information for the last executed command or function. (This way it also could be used for functions usually returning other information.)
Good idea, but cannot be done. It would be an incredible amount of work to implement and document it.
what about only transforming setkey into a function (instead of a command)?

admin
Site Admin
Posts: 66678
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how to check whether setkey was successful ?

Post by admin »

A troublesome thing to do. I see no compelling reason to go that way.

autocart
Posts: 1391
Joined: 26 Sep 2013 15:22

Re: how to check whether setkey was successful ?

Post by autocart »

ok, no big issue. was just asking.
there still is the workarund of checking with getkey.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: how to check whether setkey was successful ?

Post by bdeshi »

You could check the file size, modified date etc before and after the setkey cmd.. If they differ, setkey was probably successful.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: how to check whether setkey was successful ?

Post by highend »

Or a hash value (what I do with my files to make sure they weren't modified)...
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: how to check whether setkey was successful ?

Post by bdeshi »

That's probably even slower than getkey since hash functions have to read the entire file.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: how to check whether setkey was successful ?

Post by highend »

Calculating a sha1 hash 100 times (in a loop) for an .ini file with two sections and 25 key-value pairs takes 47ms. Can't see an issue there.
One of my scripts helped you out? Please donate via Paypal

Post Reply