Rank: Newbie
Groups: Approved
Joined: 7/6/2020(UTC) Posts: 9 Thanks: 1 times
|
I'm trying to write a script function which accepts hotkeys and, among other things, displays hotkey names to user. I'm not sure if this is because my limited knowledge of JS but I don't understand why I can't get the same value as printed to console into a variable. Code:sp.ConsoleLog(vk.ACCEPT) //Output: "ACCEPT"
var key = ""
key = "key " + JSON.stringify(vk.ACCEPT)
sp.ConsoleLog(key) //Output: "key {}"
var key = ""
key = "key " + vk.ACCEPT.toString()
sp.ConsoleLog(key) //Output: [object Object]
How can I store vk value as a string in a variable? Edited by user Sunday, December 3, 2023 6:56:50 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 Location: Tampa, FL Thanks: 28 times Was thanked: 431 time(s) in 364 post(s)
|
Here you go. Code:var names = [];
var vks = System.Enum.GetNames(host.typeOf(vk));
for (var i = 0; i < vks.Length; i++) {
names.push(vks[i]);
}
sp.ConsoleLog(JSON.stringify(names.sort()));
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 Location: Tampa, FL Thanks: 28 times Was thanked: 431 time(s) in 364 post(s)
|
Also, you can use the .NET ToString() method on an individual one, not the JavaScript toString() version. Code:StrokesPlus.Console.Log(vk.ACCEPT.ToString());
StrokesPlus.Console.Log(JSON.stringify(vk.ACCEPT.ToString()));
Edited by user Sunday, December 3, 2023 5:01:37 PM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 7/6/2020(UTC) Posts: 9 Thanks: 1 times
|
Originally Posted by: Rob Also, you can use the .NET ToString() method on an individual one, not the JavaScript toString() version. Code:StrokesPlus.Console.Log(vk.ACCEPT.ToString());
StrokesPlus.Console.Log(JSON.stringify(vk.ACCEPT.ToString()));
Thanks a lot , Rob. I totally forgot it's all .Net based.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close