Posts: 1,083
Threads: 256
Joined: Jul 2022
04-05-2025, 08:07 AM
(This post was last modified: 04-05-2025, 08:25 AM by Davider.)
After using QM for a long time, I’ve created a large number of regular and member functions. Since my programming skills are not very advanced, these functions are frequently modified.
When I share macro scripts that use these functions with my friends, I always have to save the functions being used into .txt files and send them manually. Then they have to open those .txt files and check and replace the functions one by one — it’s truly a nightmare.
Today, I made a new discovery: the text of the function names I want to export always appears in the same color (0xF08000) in the QM code editor, as shown in the image below.
https://i.ibb.co/6RR9FQp8/qm.jpg
So, is there any way to extract the text of these function names?
After obtaining these function name texts, I can exclude those starting with sub. — what's left are the regular functions and member functions that I want to export.
However, I still need to determine whether each one is a member function, because some regular and member functions share the same name, as shown in the example code below.
I’ve posted about this issue before, and it has been bothering me for a long time.
Thanks in advance for any suggestions or help!
Macro Macro1
out
out Function1(1) ;;Regular functions: Need to export
_s="hello"
out _s.Function1("world") ;;Member functions: Need to export
out sub.Function1(_s) ;;Sub-functions: No need to export
#sub Function1
function~ str's
ret s
Function Function1
Member function str.Function1
function~ str's
ret F"{this} {s}"
If the above regular functions and member functions could be exported as an xx.qml file, and then, when importing on another computer, there was a button that could directly replace existing functions with the same names, it would be incredibly convenient—just like shown in the image below. I’m not sure whether the "QM File Viewer" has its source code publicly available.
https://i.ibb.co/nqTxFSV3/im.jpg
Posts: 12,140
Threads: 142
Joined: Dec 2002
Scintilla messages can be used to get text text with a color. Actually color is an attribute of a Scintilla style, so need to learn Scintilla styling API. But note that would also need to extract names of functions used in these used functions and so on. I would not try this way.
Another way: menu Run > Make exe > Show added items > OK. But it will not work for macros containing QM functions that can't be used in exe.
Quote:If the above regular functions and member functions could be exported as an xx.qml file
I don't know a way. Or don't remember.
I would try this: keep all shareable functions in single folder. To share, export that folder, and let they import it. When exporting, maybe there is an option to not allow to rename when importing. So they will have to delete the shared-functions folder to be able to import the new shared-functions folder.
Posts: 1,083
Threads: 256
Joined: Jul 2022
Thanks for your help.
Quote:menu Run > Make exe > Show added items > OK
Using this method, I was able to get the list of function names to be exported, as shown in the image below.
https://i.ibb.co/kgZy0ydN/ok.jpg
Additionally, is the exe-generated dialog written using publicly available QM code? I noticed that some of the dialogs are open-source, and by reviewing the open-source code, there might be a better solution.
Posts: 12,140
Threads: 142
Joined: Dec 2002
No, the "Make exe" dialog code is not open-source.
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-05-2025, 11:13 AM
(This post was last modified: 04-05-2025, 11:14 AM by Davider.)
Isn't the QM File Viewer dialog also open source?
I'm not sure what language the code for the non-open source dialogs is written in, but the related code is definitely valuable for reference. It may involve some security considerations as well...
Posts: 12,140
Threads: 142
Joined: Dec 2002
Not open-source.
C++ source code compiled to qm.exe.
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-05-2025, 12:40 PM
(This post was last modified: 04-05-2025, 12:45 PM by Davider.)
Quote:I would try this: keep all shareable functions in single folder. To share, export that folder
It's not simple and direct enough.
Using the "Show added items" method to display the list of function names in the output panel exactly meets my needs.However, the operation is not very convenient.
When importing on another computer, I still need to find a way to replace them. There is no window display, making it not very intuitive.
I currently rarely use the "generate exe" feature because debugging is not convenient enough.
Sometimes I think about sending the entire Portable.qml file to my friends, but since they also have their own custom-defined functions, it can't be directly replaced.
Posts: 1,083
Threads: 256
Joined: Jul 2022
I want to execute the getout function (to get text from the QM output panel) after generating the EXE, but it doesn't work.
https://i.ibb.co/F4WHjwhb/ass.jpg
Function getout
int h=id(2201 _hwndqm)
int lens=SendMessage(h SCI.SCI_GETTEXTLENGTH 0 0)
str s.fix(SendMessage(h SCI.SCI_GETTEXT lens+1 s.all(lens)))
s.setfile("$desktop$\fs.txt")
Posts: 12,140
Threads: 142
Joined: Dec 2002
I guess getout is executed before the new text is printed. Let the "after" function create new thread (mac) that waits 200 ms and then calls getout. Or timer.
Posts: 1,083
Threads: 256
Joined: Jul 2022
not work
Macro Getout2
0.5
int h=id(2201 _hwndqm)
int lens=SendMessage(h SCI.SCI_GETTEXTLENGTH 0 0)
str s.fix(SendMessage(h SCI.SCI_GETTEXT lens+1 s.all(lens)))
ARRAY(str) a; findrx(s "^<[^>]+>(.+)$" 0 4|8 a)
for _i 0 a.len
,str n=a[1 _i].trim
,_s.getmacro(n)
,_s.setfile(F"$desktop$\{n}.txt")
Posts: 12,140
Threads: 142
Joined: Dec 2002
Example of "after" function with delayed getout code.
Function exe_after_delay_getout
mac "sub.Thread"
ret 1
#sub Thread
0.5
int h=id(2201 _hwndqm)
int lens=SendMessage(h SCI.SCI_GETTEXTLENGTH 0 0)
str s.fix(SendMessage(h SCI.SCI_GETTEXT lens+1 s.all(lens)))
mes s
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-05-2025, 03:44 PM
(This post was last modified: 04-05-2025, 03:45 PM by Davider.)
Thanks for your help.
Is it possible to call different sub-functions within a single function using two parameters, as shown in the image below:
https://i.ibb.co/35V5p6p1/exe.jpg
The sub-function addManifest is executed before generating the exe, using the parameter /a.
The sub-function saveFun is executed after generating the exe, using the parameter /s.
This approach would make the operation much more convenient. Is it possible?
Macro Getout
mac "sub.saveFun"
ret 1
#sub saveFun
0.3
int h=id(2201 _hwndqm)
int lens=SendMessage(h SCI.SCI_GETTEXTLENGTH 0 0)
str s.fix(SendMessage(h SCI.SCI_GETTEXT lens+1 s.all(lens)))
ARRAY(str) a; findrx(s "^<[^>]+>(.+)$" 0 4|8 a)
for _i 0 a.len
,str n=a[1 _i].trim
,_s.getmacro(n)
,_s.setfile(F"$desktop$\{n}.txt")
del- "$Temp$\_Temp.exe"
#sub addManifest
_s=
;BEGIN PROJECT
;main_function Macro1
;exe_file $Temp$\_Temp.exe
;icon <default>
;manifest $qm$\default.exe.manifest
;on_after Getout
;flags 7
;guid {25416EFA-F9D9-4043-AC7C-50020F98DDB3}
;END PROJECT
Posts: 12,140
Threads: 142
Joined: Dec 2002
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-05-2025, 09:47 PM
(This post was last modified: 04-05-2025, 10:39 PM by Davider.)
I want to use the hotkey Alt+F3 to perform temporary compilation and export functions.
I’d like to know if there’s a simple way to implement the compilation functionality( Ctrl+click(compile)).
Function addManifest
Trigger AF3
str mf=
;;
;;BEGIN PROJECT
;;main_function Macro1
;;exe_file $Temp$\_Temp.exe
;;icon <default>
;;manifest $qm$\default.exe.manifest
;;on_after exportFun
;;flags 7
;;guid {25416EFA-F9D9-4043-AC7C-50020F98DDB3}
;;END PROJECT
_s.getmacro
_s.addline(mf)
_s.setmacro
;//run Ctrl+click(compile)
Function exportFun
mac "sub.exportFun"
ret 1
#sub exportFun
0.3
int h=id(2201 _hwndqm)
int lens=SendMessage(h SCI.SCI_GETTEXTLENGTH 0 0)
str s.fix(SendMessage(h SCI.SCI_GETTEXT lens+1 s.all(lens)))
ARRAY(str) a; findrx(s "^<[^>]+>(.+)$" 0 4|8 a)
for _i 0 a.len
,str n=a[1 _i].trim
,str fo=a[1 0].trim
,_s.getmacro(n)
,_s.setfile(F"$desktop$\{fo}\{n}.txt")
del- "$Temp$\_Temp.exe"
The following code imports the text of all functions from a folder.
I need to create a trigger that activates when a folder is dragged and dropped into the file list on the left side of QM.
Is this possible?
Function importFun
out
Dir d
foreach(d "$desktop$\Macro1\*" FE_Dir)
,str path=d.FullPath ;;out path
,str name=d.FileName; name.getfilename(name) ;;out name
,_s.getfile(path)
,_s.setmacro(name)
Posts: 12,140
Threads: 142
Joined: Dec 2002
Quote:a simple way to implement the compilation functionality(Ctrl+click(compile))
Probably will need to automate Ctrl+click(compile).
Quote:a trigger that activates when a folder is dragged and dropped into the file list on the left side of QM
There is no "dropped" trigger.
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-09-2025, 01:25 PM
(This post was last modified: 04-09-2025, 01:35 PM by Davider.)
Quote:a simple way to implement the compilation functionality(Ctrl+click(compile))
men 33233 _hwndqm; 'Y
about importFun
The exported x.qml file seems to be an SQLite database file. Was it eventually merged into the main.qml database?
If so, is there a way to directly import the code from the exported str.Function1.txt file into the main.qml database using SQLite commands?
I need a simple and fast way to replace the code of exported functions into the main.qml file.
Posts: 12,140
Threads: 142
Joined: Dec 2002
I forgot many things how QM works, so please don't assume that my answers are correct or that it is the best way. You can find all this info in QM Help.
Yes, qml files are sqlite databases.
Yes, when importing, items from the qml file are merged into the main qml file. Unless importing as shared file.
QM has public documented functions to work with the main qml file. Simple: qmitem, str.getmacro/setmacro, SilentImport, SilentExport, maybe more. Advanced: SqliteBegin etc (accessing the database). But importing is not so simple. There is no way to correctly import using sqlite functions.
Quote:I need a simple and fast way to replace the code of exported functions into the main.qml file.
If I correctly understand, you prefer to export functions as multiple txt files, not as single qml file. Then maybe your posted importFun is the best way.
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-10-2025, 01:36 AM
(This post was last modified: 04-10-2025, 01:54 AM by Davider.)
My problem has been successfully solved, and it wouldn’t have been possible without your help and guidance. Thank you so much!
The QM help is a treasure trove — almost all the detailed issues can surprisingly be found in it.
Quote:I forgot many things how QM works
I'm just curious — how many years has QM been in continuous development? On which system was it first released? Windows 95?
I can't find the download link for the old versions anymore. Sometimes I really want to install the very first version of QM on a Windows 95 system just for fun.
Posts: 12,140
Threads: 142
Joined: Dec 2002
04-10-2025, 04:14 AM
(This post was last modified: 04-13-2025, 03:51 AM by Gintaras.)
Started in previous century on Win98...
Posts: 1,083
Threads: 256
Joined: Jul 2022
04-13-2025, 01:52 AM
(This post was last modified: 04-13-2025, 01:54 AM by Davider.)
That's impressive! I know QM is quite late, but I only started using computers with Windows 98.
|