Jump to content

Recommended Posts

Posted

I try not to make things global unless necessary -- not really sure why I just figured it took more memory and was thought to be bad coding style.

($var1, $var2) = _ini($file_name, $log_file)

func _ini($file_name, $log_file)
    #cs
    [EventArc]
    DESTINATION=C:\Program Files\NISP_UTILITIES
    LOGFILE=C:\Program Files\NISP_UTILITIES\EventArc.txt
    #ce
    local $_file_name = IniRead(@ScriptDir & "\EventArc.ini", "EventArc", "DESTINATION", $file_name)
    local $_log_file = IniRead(@ScriptDir & "\EventArc.ini", "EventArc", "LOGFILE", $log_file)
;ConsoleWrite($var & @CRLF)

        return($_file_name, $_log_file)
EndFunc

The above example doesn't seem to produce the results I expected :D

Can anyone point me in the right direction please? Should I just make these variables global and be done with it?

Thanks Again,

Avery

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Posted

... or return a structure.

You should be shot for even thinking this, much less suggesting it. DllStruct is not a general data storage facility.
Posted

You should be shot for even thinking this, much less suggesting it. DllStruct is not a general data storage facility.

:D

Sorry, but I mean the following.

$tSTRUCT = '...'
$Size = ...
$hMem = _MemGlobalAlloc($Size)
$pMem = _MemGlobalLock($hMem)
$pStruct = DllStructCreate($tSTRUCT, $pMem)
DllStructSetData($pStruct, ...)
_MemGlobalUnlock($hMem)
_MyFunc($hMem)

But if it came about that, Valik, look at _WinAPI_GetWindowPlacement() function from the AutoIt package. It returns a structure. Why?

:o

Posted

:D

Sorry, but I mean the following.

$tSTRUCT = '...'
$Size = ...
$hMem = _MemGlobalAlloc($Size)
$pMem = _MemGlobalLock($hMem)
$pStruct = DllStructCreate($tSTRUCT, $pMem)
DllStructSetData($pStruct, ...)
_MemGlobalUnlock($hMem)
_MyFunc($hMem)
Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess?

But if it came about that, Valik, look at _WinAPI_GetWindowPlacement() function from the AutoIt package. It returns a structure. Why?

Are you really this stupid? The WinAPI functions are wrappers around DllCall() and DllStruct stuff. It is the exact expected use for DllStruct. Passing arbitrary information around is stupid. Passing information to or receiving information from a DLL is the intended purpose. That's why it's called DllStruct. Not just Struct. Get it?
Posted

I love Valik... he's so refreshingly free of <insert politically correct terminology here>

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted

Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess?

Are you really this stupid? The WinAPI functions are wrappers around DllCall() and DllStruct stuff. It is the exact expected use for DllStruct. Passing arbitrary information around is stupid. Passing information to or receiving information from a DLL is the intended purpose. That's why it's called DllStruct. Not just Struct. Get it?

I think that in some cases it may be useful. But I will not argue with you, Valik. In general, I agree with you.

:D

Posted

I think that in some cases it may be useful. But I will not argue with you, Valik. In general, I agree with you.

:D

It is only useful to people too lazy or too stupid to come up with a more elegant solution to the problem even after one of the developers flat out says "you shouldn't do that".
Posted

It is only useful to people too lazy or too stupid to come up with a more elegant solution to the problem even after one of the developers flat out says "you shouldn't do that".

Valik, then please tell me how to AutoIt, you can "bind" variable for a given area of memory?
Posted

Valik, then please tell me how to AutoIt, you can "bind" variable for a given area of memory?

Please tell me why you need to do it outside the context of needing to pass memory to a DLL?
Posted

You don't.

Just do as he says. Use ByRef (example 1) or arrays (example 2).

Example 1:

Dim $var1
Dim $var2

$ret = _ChangeVars ("I", $var1, $var2)

MsgBox (0, "", "$ret = " & $ret & @CRLF & "$var1 = " & $var1 & @CRLF & "$var2 = " & $var2)

Func _ChangeVars ($name, ByRef $r1, ByRef $r2)
    $r1 = "This is a return value?"
    $r2 = "This is another!"
    Return "The function was successful!"
EndFunc

Example 2:

$ret = _ChangeVars()

MsgBox(0, "", "$ret[0] = " & $ret[0] & @CRLF & _
        "$ret[1] = " & $ret[1] & @CRLF & _
        "$ret[2] = " & $ret[2])

Func _ChangeVars()
    Local $aRet[3]
    $aRet[0] = "This is a return value?"
    $aRet[1] = "This is another!"
    $aRet[2] = "The function was successful!"
    Return $aRet
EndFunc  ;==>_ChangeVars
Posted

Please tell me why you need to do it outside the context of needing to pass memory to a DLL?

This extends the possibilities of language programming.

I had a few moments when there was such a need. I kept the data in the heap.

Posted (edited)

This extends the possibilities of language programming.

I had a few moments when there was such a need. I kept the data in the heap.

Don't confuse "I'm not smart enough to solve this problem" with "I needed to abuse the language to solve this problem". Storing data on the heap in AutoIt is stupid and unnecessary unless you are interacting with a DLL with that memory. Any other use is just poor design on your part.

You and people like you are the reason we can't have a more convenient syntax for DllStruct. We can't add something nice like:

DllStruct
    int data
    char[256] string
EndDllStruct

People like you will abuse that and try to use it for things it shouldn't be used for.

But, I guess you know better than a developer. Carry on.

Edited by Valik
Posted (edited)

Valik, you gave me a tool (AutoIt), I applied it, but not quite in accordance with the instruction, but the result turned out positive, and consequently, I was satisfied with this tool. The fact that I have used this tool is not in accordance with the instructions, you have successfully explained to me, thank you for that.

DllStruct
    int data
    char[256] string
EndDllStruct
I think it's a good idea. But it is not for this topic.

Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess?

:D

Valik, my profession, too, is based on constant communication with people, most of them are very stubborn. I constantly have to prove to them the obvious and a lot of time explaining to them the same thing. I well understand you.

Good luck to you.

:o

Edited by Yashied

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...