Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy content's of one macro to the other and compile to exe
#1
For example:
Code:
Copy      Help
if(scan("5 ITEM.bmp" 0 r 1 70))

Now the item's macro keeps checking will change, as he goes from item 1 to item 2 item 3 and so on. Is it somehow posible to make a variable containing the name of the bmp, in this case 5 ITEM.bmp. And put that instead of the actual name so it's like this:
Code:
Copy      Help
str Item.getfile("C:\Items\CurentItem.txt")
if(scan("item" 0 r 1 70))
...

where CurentItem.txt contains the name of the bmp: 5 ITEM.bmp, than variable "item" takes it. In the next loop it will contain 6 ITEM.bmp for example ect.

This would be extremly usefull as i wouldnt have to rewrite the entire macro and functions for every diferent item he needs to check. This way code stays the same and when the loop starts he will just change the name of the item bmp in CurentItem.txt and use it trought the macro..
I hope managed to describe where im going wiith this. If i need to explain more please let me know.
Thank you for your help.

Update: I managed to do similar thing using image macros bmp's and to change the contents of the "item" using the code
Code:
Copy      Help
_s.getmacro("ITEM5.bmp"); _s.setmacro("ITEM.bmp")
#2
Oh damn, i finished everything and now it says it wont compile code
Code:
Copy      Help
s.setmacro("ITEM")
to .EXE Sad Sad Sad
#3
If using bmp macros, one of solutions would be like this:
Code:
Copy      Help
#exe addtextof "Macro1658.bmp"

int i=1658
if(scan(F"macro:Macro{i}.bmp" 0 0 1))
,out "found"

Need to add all bmp macros with #exe addtextof, because QM cannot add automatically because the string in scan uses a variable.
Similar would be with files.
#4
Thank you for your ansver but i have trouble understanding what i need to do here. I have around 18 bmp macros and 10funtions i thoth i could use like text files to store numerical and text values i work with in the macro (i did this so id avoid using a folder on my computerwith text files that do the same purpoce so when i export to exe id have one file that has all the things i need).
Where do i put the #exe addtextof "Macro1658.bmp" for each one? Do i just make a function containing a list of these with my macro bmp's and functions (=text files) or something else. Can i than use s.setmacro ("ITEM") comand or i need to change it too?
Thank you for your patience, im still green at this..

i just tried doing this:
Code:
Copy      Help
#exe addtextof "item1"
#exe addtextof "item2"
_s.getmacro("item1");
_s.setmacro("item2")

And i got:
Error in Function3: cannot be used in exe.
Cannot make exe. Error 4, failed to compile. And its pointing to the _s.setmacro

The content of the macro/function is the key. The way to copy contents from one to another. And the ability to compile to exe at the end. Maby there is another way to go about this that i dont know..

Exactly what i did: take contents from one macro.bmb / function (some text) store the contents into variable and than copy contents from a variable to the other macro.bmp / function. Variable playing an intermediary because i dont know a way to copy directly from one macro to the other or function to another. If there just culd be a way to somehow dont use the variable and dont use expresion "setmacro" than maby it would work..
Any ideas?
#5
After hours of trying and reading help i found that " str.setmacro" is on the list of unavailable functions in .exe Sad So unles there is some other way to copy contents from one macro.bmb / function to another im at a dead end Sad I just don't get why this is unavailable when str.getmacro is..
#6
In exe, str.setmacro is not useful and therefore not supported. In your case, setmacro is not the best way. Use variables. Like in my previous example, or like

str variable="file.bmp"
if(scan(variable ...

Place #exe... anywhere. If the function is added to exe, these bmp macros also will be added.

Example with 3 bmp macros (all will be added to exe):
Code:
Copy      Help
;/exe

#exe addtextof "item1.bmp"
#exe addtextof "item2.bmp"
#exe addtextof "item3.bmp"

int i
for i 1 4
,out F"macro:item{i}.bmp"
,if(scan(F"macro:item{i}.bmp" 0 0 1))
,,out "found"

Example with 3 bmp files (all will be added to exe if "Auto add files" checked):
Code:
Copy      Help
;/exe

str allFiles=
F
;:1 item1.bmp
;:2 item2.bmp
;:3 item3.bmp

int i
for i 1 4
,out F":{i} item{i}.bmp"
,if(scan(F":{i} item{i}.bmp" 0 0 1))
,,out "found"

Run to test how works. At first create these macros or files.


Forum Jump:


Users browsing this thread: 1 Guest(s)