You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Simple answer is no
Gosub, Function, Sub must point to actual code.
You can gosub to code as the result of a test on a variable (and the address of the code can be stored in a dword) but programs can only run code. If your sting contained binary machine code but not text
Given that you can get a pointer to code, I can't see why you should not be able to copy code into a string and execute it. However, there is a constraint on GOSUB that the label should be within the current block, I'm not sure how, or if, the generated code enforces this if you GOSUB to a CODEPTR. Why not give it a try?
Given that you can get a pointer to code, I can't see why you should not be able to copy code into a string and execute it.
????
If you can get a pointer to the code, you can CALL it, GOTO it or GOSUB to it using the DWORD option provided by the compiler for all three verbs. Why bother getting its length, copying it into a string after allocating virtual memory with execute permissions and all that stuff?
XX$= STR$ ( CODEPTR (Air_Injector) )
point = VAL(XX$)
GOSUB DWORD point
Your original code of XX$ = Air_Injector elicited an error presumably
because Air_injector is a label and XX$ is a string variable .
The three lines of code above could be written as ;
GOSUB DWORD CODEPTR(Air_Injector)
The main advantage of the GOSUB DWORD implementation is that Air_Injector need not be within the scope of the calling function; where as
GOSUB Air_Injector
must be within the scope, as well as various forms of the
'
On var GOSUB Air_Injector implementation
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment