Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric values get saved not as strings, but as null/true/false #4

Closed
Drugoy opened this issue Dec 25, 2014 · 4 comments
Closed

Numeric values get saved not as strings, but as null/true/false #4

Drugoy opened this issue Dec 25, 2014 · 4 comments

Comments

@Drugoy
Copy link

Drugoy commented Dec 25, 2014

STR:

  1. Run this script
  2. Fill "name" = 2 and "default route" = 3.
  3. Hit 'Save' button and save the data into an external file in JSON.
  4. Open that file (or drag'n'drop it onto the script).

Actual result:
2 and 3 got transformed to 'null'.

Expected result:
They should get saved as strings.

1 and 0 get transformed to 'true' and 'false' respectively.

@cocobelgica
Copy link
Owner

I've added a MsgBox under the Save label and apparently both Name and DefRoute are blank, hence, converted to null: (put the ff as first line of Save label)

MsgBox % "Name: " . machines[1].Name . "nDefRoute: " . machines[1].DefRoute
`

I can't see anywhere in your code wherein you try to retrieve the values in the respective Edit controls. That's why they're blank.

@Drugoy
Copy link
Author

Drugoy commented Jan 4, 2015

  1. I might have mistakenly copied the wrong code, because I've tried now the script from the url I gave you and it seemed to not work: the script should save json into a file, but in fact it just created a blank file. I've now updated the code on that url and it now works and you should be able to reproduce the issue using the STR provided in the initial post.
  2. I was not talking about the Edit controls being empty or not, I was referring to the work of your lib: you confirm that if 'name' and 'defroute' are blank - then their values get converted into JSON format as 'null'.
    But I, as a user, expect them to be converted as strings (obviously empty ones).
    The same goes for numeric values: imagine a different script where user would store some numbers into 'edit' controls and then would make an attempt to convert them to JSON using your lib: all the positive numbers would get converted to 'true' and the numeric values would just get lost!

It looks like a bug to me, although to you it probably looks like a 'the way it was designed'.
If so - I don't insist on committing changes to your lib if you don't want that. But then, please, at least tell me how to do what I want and I will commit these changes to my local copy of your lib.
Thanks in advance.

@cocobelgica
Copy link
Owner

I guess you have a point. Since AHK does not support null natively and true/false are simply 1 and 0 (respectively), I opted to output "", 1 and 0 as they are. See commit a7be08f

@Drugoy
Copy link
Author

Drugoy commented Jan 7, 2015

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants