AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LowLevel & dynamic code
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Mon Jun 09, 2008 2:56 am    Post subject: Reply with quote

New version released. The download includes LowLevel.ahk, code.ahk and LowLevel.chm, which documents both scripts in addition to a number of AutoHotkey structures.
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4517
Location: Boulder, CO

PostPosted: Mon Jun 09, 2008 4:13 am    Post subject: Reply with quote

Lexikos wrote:
New version released.
It looks fantastic! (I need a couple of days to comprehend all these.) It finally opened the door for the popup calculator to support genuine functions, with true parameters and local variables.

Have you considered making an AHK version, which natively supports dynamic code generation?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Mon Jun 09, 2008 8:21 am    Post subject: Reply with quote

Laszlo wrote:
Have you considered making an AHK version, which natively supports dynamic code generation?
Yes. It seems more worthwhile than writing an AutoHotkey parser around code.ahk, since all of the parsing and syntax-checking (most of which I would not bother to rewrite) is already done.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Sun Jul 13, 2008 6:26 pm    Post subject: Reply with quote

When attempting to incorporate LowLevel.ahk either via #include or as a AutoHotKey Lib ... I get the following error ...

Line Text: `sA_CaretX
Error: The leftmost character above is illegal in an expression.

.. when attempting to call any included function (like .. __int() or LowLevel_init()).

I'm using AutoHotKey Version 1.0.47.06.

I have never used this before, so I'm likely doing something stupid. Any help would be appreciated
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Sun Jul 13, 2008 10:19 pm    Post subject: Reply with quote

Look for the following:
Code:
    ( Join`s
A_AhkPath A_AhkVersion A_AppData A_AppDataCommon A_AutoTrim A_BatchLines
A_CaretX A_CaretY A_ComputerName A_ControlDelay A_Cursor A_DD A_DDD A_DDDD
...
`s is a special escape code recognised only by continuation sections, meaning a space character. Have you by chance used the #EscapeChar directive? If not, I can't explain why that would happen, but I can suggest you try changing `s to `%A_Space% or `, (comma).
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Sun Jul 13, 2008 10:28 pm    Post subject: Reply with quote

I was using #EscapeChar ... removed and all is well.

Thank You
Back to top
rani



Joined: 18 Mar 2008
Posts: 144

PostPosted: Mon Jul 14, 2008 5:28 am    Post subject: Reply with quote

numput, numget

by using the bit mechanizm in AHK:

is it possible to set and then also get
a bit value=0 or bit=1
in specific location in a var ?

means
I set bit=1 as binary (no val=1 as asci) set in offset=20001234 (bit location very large)
in varcode myvar, let say

and then I want to retrieve (get) the bit value from above offset

can it be done ?

any help will be appreciated

rgds
ell
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4517
Location: Boulder, CO

PostPosted: Mon Jul 14, 2008 6:16 am    Post subject: Reply with quote

You could use the Windows bitmap functions exported by ntdll.dll. See an example here.
Back to top
View user's profile Send private message
bmcclure



Joined: 24 Nov 2007
Posts: 766

PostPosted: Sun Oct 26, 2008 6:02 pm    Post subject: Reply with quote

Sorry to resurrect this topic.

I want to call a dynamic function with a dynamic number of parameters. I can't figure out a way to do this with the new built-in dynamic function calling. It seems you still need to know how many parameters to pass before calling it.

I'd like to dynamically call a full function with parameters and all.

Is there a way to do this with the built-in dynamic function feature, or should I revert to using the LowLevel.ahk library to run it as an __expr() ?
_________________
Ben

My Trac projects
My Wiki
[Broken] - My music
Back to top
View user's profile Send private message
freakkk



Joined: 29 Jul 2005
Posts: 179

PostPosted: Sun Oct 26, 2008 8:35 pm    Post subject: Reply with quote

bmcclure wrote:
Sorry to resurrect this topic.

Don't be; these are extremely useful functions that I use constantly!

Take a look at AutoHotkey_L (Lexikos' custom build)

Improvements to Dynamic Function Calls
Quote:
When calling a function dynamically, any number of parameters may be passed. This allows functions to accept only the parameters they require, similar to message-monitoring functions. For example:


If you don't plan on using that build- than LowLevel is the way to go.
_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
bmcclure



Joined: 24 Nov 2007
Posts: 766

PostPosted: Sun Oct 26, 2008 9:31 pm    Post subject: Reply with quote

Hey, thanks a lot! The improvement to dynamic function calls looks perfect for my needs this time around. It would be nice if that was built into AHK, however, so that my users wouldn't need to have a custom build to run my code from source.

Hmmm... hard to decide which to use Smile
_________________
Ben

My Trac projects
My Wiki
[Broken] - My music
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Sun Oct 26, 2008 10:46 pm    Post subject: Reply with quote

Code.ahk (in LowLevel.zip) can be used to generate a dynamic expression, such as a function call where the number of parameters are decided at run-time. All functions are documented in LowLevel.chm.
Code:
LowLevel_init()
; Initialize a code generator.
cg := code_gen()

var = 1

; Begin an expression line.
code_line(cg, ACT_EXPRESSION:=3)
; Begin a text/expression arg (expression lines have only one).
code_arg(cg, 0, true)
; Append a function deref/call to the expression.
code_arg_deref(cg, "MyFunc", __findFunc("MyFunc"), true)
; Append the open parenthesis (for valid function-call syntax).
code_arg_write(cg, "(")
; Append a var deref.
code_arg_deref(cg, "var", __getVar(var), false)
; Append the rest of the expression.
code_arg_write(cg, ",2)")
; Finalize the code. Not really necessary in this case, except to use code_run.
ch := code_finalize(cg)
; Call the function.
code_run(ch)
; Delete the code and code generator.
code_delete(ch)
code_gen_delete(cg)

MyFunc(a, b) {
    ListLines
    MsgBox %a%, %b%
}
The code need only be deleted and recreated when the number of parameters changes.
Back to top
View user's profile Send private message Visit poster's website
bmcclure



Joined: 24 Nov 2007
Posts: 766

PostPosted: Mon Oct 27, 2008 3:47 am    Post subject: Reply with quote

Couldn't a function be dynamically called with __expr(), or does it have to be constructed with calls to the code_ functions?
_________________
Ben

My Trac projects
My Wiki
[Broken] - My music
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Mon Oct 27, 2008 8:33 am    Post subject: Reply with quote

Which method is best depends on the usage.
  • If the number of parameters or called function is different each time, __expr seems to be the most efficient.
  • If not, a one-time cost of generating code is acceptable as executing the code is much faster. (Once the code is generated, it performs identically to code placed directly in the script.)
Back to top
View user's profile Send private message Visit poster's website
weiterbilder



Joined: 30 Oct 2008
Posts: 33

PostPosted: Wed Nov 19, 2008 6:30 pm    Post subject: Reply with quote

What can you do with it in general. How is ll meant?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 5 of 10

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group