Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code in variables or resources
#4
Thanks for your help.
Quote:#exe addtextof "<script>"
I don’t quite understand what this line of code does.

In the function `getSubCode` below, I used this line.

1. When I run the macro `getSubCode_T` in QM, it works successfully!
2. But when I compile `getSubCode_T` into an EXE file and run it, it fails.

I use the `getSubCode` function in many macros, and I’ve tried various solutions but haven’t been able to resolve the issue.

Can you help me? In any case, thank you very much!

Function getSubCode_T
 
Code:
Copy      Help
out

getSubCode("a" _s); out _s
getSubCode("b" _s); out _s

#sub a
A

#sub b
B

Function getSubCode
Code:
Copy      Help
function $subName str&code ;;Get text from the sub-function

#exe addtextof "<script>"
#opt nowarnings 1
opt noerrorshere 1

int iid=+getopt(itemid 1)
code.getmacro(iid)

str m="^#sub sn.*[]"; m.findreplace("sn" subName)
str s; int l i=findrx(code m 0 8 s) ;;
if i!=-1
,s.trim
,;out s
,foreach _s code
,,_s.trim
,,if(_s=s) break
,,l+1
else
,end F"#sub {subName} Not found!"
for _i l+1 numlines(code)
,str s_.getl(code _i)
,if(s_.beg("#sub") or s_.beg(" BEGIN PROJECT"))
,,break
,else
,,str cf.addline(s_ -1)
cf.rtrim;
if(empty(cf)) end F"#sub {subName} content is empty!"

code=cf


Messages In This Thread
Code in variables or resources - by Davider - 08-03-2025, 01:50 PM
RE: Code in variables or resources - by Gintaras - 08-03-2025, 02:27 PM
RE: Code in variables or resources - by Gintaras - 08-03-2025, 02:33 PM
RE: Code in variables or resources - by Davider - 08-04-2025, 12:33 AM
RE: Code in variables or resources - by Davider - 08-04-2025, 03:08 AM
RE: Code in variables or resources - by Gintaras - 08-04-2025, 03:48 AM
RE: Code in variables or resources - by Davider - 08-04-2025, 04:01 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)