Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get #ret text in exe
#1
The following `getRetCode` function runs normally in QM, but after generating the exe file, it fails to retrieve the text after #ret. Is this possible? What changes need to be made? Thanks in advance for any suggestions and help.

I noticed that the following code can use the text after #ret normally in the exe.
 
Code:
Copy      Help
CsScript x.AddCode("") ;;if "", gets text that follows #ret line in this macro

Macro Test
 
Code:
Copy      Help
getRetCode("" &_s 1)
mes _s

;BEGIN PROJECT
;main_function  Test
;exe_file  $my qm$\Test.exe
;icon  <default>
;manifest  $qm$\default.exe.manifest
;flags  6
;guid  {683DDF1D-6645-49E5-9124-A1CF5B4867B4}
;END PROJECT

#ret
using System;

class Program
{
,static void Main()
,{
,,// Get the operating system version information
,,OperatingSystem os = Environment.OSVersion;

,,// Output the operating system platform and version number
,,Console.WriteLine("Operating System Platform: " + os.Platform);
,,Console.WriteLine("Operating System Version: " + os.Version);
,,Console.WriteLine("Operating System Version String: " + os.VersionString);

,,// Get the service pack information
,,Console.WriteLine("Service Pack Version: " + os.ServicePack);
,}
}

Function getRetCode
Code:
Copy      Help
function $Mac str&Code_ [_Context] 

#opt nowarnings 1
opt noerrorshere 1

if(!Mac or (Mac>=0x10000 and !Mac[0]))
,int iid=+getopt(itemid -iif(_Context _Context 2))
else
,iid=qmitem(Mac 1); if(!iid) end ERR_MACRO
Code_.getmacro(iid)

int n i=findrx(Code_ "^#ret\b.*[]" 0 8 _i)
if i>=0 
,i+_i-2
,Code_[i]=0; n=numlines(Code_)-1; Code_[i]=13
,Code_.replace(_s.all(n 2 10) 0 i) 
else if 0=findrx(Code_ "^[ ;]*[/\\](?![/\*]).*[]" 0 0 _i)
,Code_.remove(0 _i-2) 

Code_.trim
#2
Click AddCode in code, press F2, and you'll see

#exe addtextof "<script>"

Then click #exe and press F1 to read more.
#3
thank you so mutch!


Forum Jump:


Users browsing this thread: 1 Guest(s)