AutoHotkey Community

It is currently May 27th, 2012, 1:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: December 22nd, 2011, 10:09 pm 
Online

Joined: February 19th, 2010, 8:07 pm
Posts: 616
Hi,

I didn't find the following behavior documented in the help file, and it is something that i dont consider as desired, so i will post it here as a bug just in case it is one:

Code:
#NoEnv

VarSetCapacity(Q, strlen("test")), StrPut("test", &Q)
msgbox % Q


Thing is that as soon as you comment the #NoEnv directive, the msgbox will be empty.

I have checked the contents of the variable using a hexviewer and the variable pointer does contain the data but for some reason it is not shown.

It happens in both Ansi & Unicode versions of L v1.1.05.04

The name of the variable doesnt change the results, which considering that NoEnv has to do with environment variables, i thought it should.

(Thanks to adabo for helping me find this little bug.)

_________________
Main Project: AutoHotkey Toolkit
Unless specified otherwise all my code is written for the latest Autohotkey L Unicode version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2011, 10:41 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Sounds like this bug report.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2011, 11:08 pm 
Online

Joined: February 19th, 2010, 8:07 pm
Posts: 616
Yes very similar indeed but is this an expected behavior?
because i find no logic in what has NoEnv to do with all that :shock:

_________________
Main Project: AutoHotkey Toolkit
Unless specified otherwise all my code is written for the latest Autohotkey L Unicode version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2011, 11:43 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Code:
;#NoEnv

VarSetCapacity(Q, strlen("test")), StrPut("test", &Q),VarSetCapacity(Q, -1)
msgbox % Q ; works
Uhh... why does #NoEnv magically help AHK read the variables?

Edit:
Code:
;#NoEnv
VarSetCapacity(Q, strlen("test"), 1), StrPut("test", &Q)
msgbox % Q ; works
Code:
;#NoEnv

VarSetCapacity(Q, strlen("test"), 0), StrPut("test", &Q)
msgbox % Q ; doesn't work
So it has to do with the null-terminator

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2011, 2:47 am 
Online

Joined: February 19th, 2010, 8:07 pm
Posts: 616
nimda wrote:
So it has to do with the null-terminator


Yes after reading the whole topic linked by jaco0646 i arrived to the same conclusion!

The interesting point here is that this happens with that particular directive... Lexikos explains why on the other post as well.

But it is kind of curious anyways.

_________________
Main Project: AutoHotkey Toolkit
Unless specified otherwise all my code is written for the latest Autohotkey L Unicode version.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group