Page 1 of 1

way to make certain lines not executed on certain platforms.

Posted: Mon Jul 29, 2013 12:12 am
by Bugala
If i correctly remember, you have mentioned that trying to compile for example ChangeMousePointer command to Android would result in error.

Therefore I would be asking that you would add some way to exclude some of the commands in case it is compiled for Android device.


As example, now you are using /* */ for comments, something similar to that could be useful.

And even better you could make it so that instead of having just an option for android and non android devices, you oculd give freedom for programmer to decide which parts are not executed.

For example, it could be that you could use:
1/* */1 , 2/* */2 , 3/* */3

and then the first line of code could tell the compiler which numbers would be executed and which ones left out, it could be for example:

#DONTCOMPILE 1, 2, 3

meaning that it wont compile any of that stuff between 1/* and */1 or between 2/* and */2 or between 3/* and */3

For that could be useful for testing purposes too, to for example bug hunt when you could "comment" and "uncomment" some parts of code back and forth just by putting/removing one number from first line of code.

Or you oculd easily make speedtests upon which way is faster when you could check the difference by just adding/removing one number.



But mainly I would like this feature so that I could be programming in such way that both Android and Computer versions would share same code, and then when there is for example ChangeMousePointer part, I would simply put those lines dealing with that between comments that work in such way that when compiling to andorid it ignores them and when compiling to computers, it would execute them.

Re: way to make certain lines not executed on certain platforms.

Posted: Tue Aug 06, 2013 2:03 pm
by airsoftsoftwair
This is currently possible at runtime by checking the "Platform" table item returned by GetVersion(). This allows you to skip the execution of certain parts of the code depending on the platform Hollywood is currently running on. The only thing that is currently impossible is compile-time platform conditional behaviour. This is for example necessary because some constants, e.g. #HKEY_CLASSES_ROOT for ReadRegistryKey() are only defined on certain platforms (here: Windows) and will result in a compile-time error on the other platforms. Circumventing this problem is currently not possible but a solution is planned here, but it will have to be on the preprocessor level.

At runtime level you can simply use GetVersion(), e.g.

Code: Select all

If GetVersion().Platform <> "Android"
  CreatePointer(...)
EndIf

Re: way to make certain lines not executed on certain platforms.

Posted: Tue Aug 06, 2013 9:26 pm
by Bugala
Ah, thanks Andreas. This should already work fine for me.

Re: way to make certain lines not executed on certain platforms.

Posted: Wed Dec 18, 2019 6:41 pm
by airsoftsoftwair
Just for the record, since Hollywood 7.0 this is possible on preprocessor level using @IF.