@MAINFILE preprocessor command

Feature requests for future versions of Hollywood can be voiced here
plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

@MAINFILE preprocessor command

Post by plouf »

Hi

i propose the use of @MAINFILEin preprocessor command
the idea is to have @MAINFILE "main.hws" in all includes expect main, so compiler will know what to compile

this is usefull in case you use many includes and while playing around you want to test run (F5),
extremelly usefull in hollywood ide and/or alternatives ones

User avatar
Clyde
Posts: 315
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: @MAINFILE preprocessor command

Post by Clyde »

You've got a similar mechanism in my Hollywood extension for Visual Studio Code: viewtopic.php?f=13&t=2424
Currently using: Hollywood 8 with Visual Studio Code and hw4vsc

SamuraiCrow
Posts: 303
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: @MAINFILE preprocessor command

Post by SamuraiCrow »

As a workaround, you can pass in a string constant into your Hollywood script (compiled or through the interpreter) to prepend onto the path of your includes. This allows you to put all of your includes in one directory and callers into another. To make a string constant from the command prompt, you have to use double square brackets, I think.
I'm on registered MorphOS using FlowStudio.

User avatar
airsoftsoftwair
Posts: 4199
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: @MAINFILE preprocessor command

Post by airsoftsoftwair »

Don't understand this proposal... please elaborate :)

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: @MAINFILE preprocessor command

Post by plouf »

if you have

mainfile.hws

Code: Select all

@INCLUDE "file1.hws"
@INCLUDE "file2.hws"

Print("hello")

file1.hws

Code: Select all

@MAINFILE "mainfile.hws"

a =1
file2.hws

Code: Select all

@MAINFILE "mainfile.hws"

b=1
Compiling ANY of the above files (pressing F5 in IDE) will correct compile and print Hello

Bugala
Posts: 915
Joined: Sun Feb 14, 2010 7:11 pm

Re: @MAINFILE preprocessor command

Post by Bugala »

Not sure, but I guess your problem would be solved by using simply #INCLUDE for the mainfile.hws?

For I think when you include some file, it will also include all the includes the included file includes.

But Andreas can probably confirm this one since I am not sure.

Also, not doing exactly what you are after, but you might find Allanons Appbuilder useful, at least I personally have found it extremely useful in some cases, it can save you a load of time and hassle: viewtopic.php?f=7&t=1097

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: @MAINFILE preprocessor command

Post by plouf »

nop since

a) will end in endless loop of including mainfile, mainfile will include file1, file1 will include again mainfile etc
b) the possibility of INCLUDEONCE (this is another idea :)) will be better but will not follow include order
as using includeonce will have diffirend order of including file dependeing on which file you are compiling

User avatar
Clyde
Posts: 315
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: @MAINFILE preprocessor command

Post by Clyde »

The problem of plouf's example I see is that if you add such a @mainfile tag you would limit that specific file to be in included just in this one main files. Sou you couldn't use a (helper) file in other projects (or you would have more than one version of this file). IMHO not so convinient. I think it would be better to have a project/workspace management (like my extentension for VS Code has ;-) ).
Currently using: Hollywood 8 with Visual Studio Code and hw4vsc

User avatar
airsoftsoftwair
Posts: 4199
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: @MAINFILE preprocessor command

Post by airsoftsoftwair »

Clyde wrote:
Sun May 10, 2020 11:09 am
The problem of plouf's example I see is that if you add such a @mainfile tag you would limit that specific file to be in included just in this one main files. Sou you couldn't use a (helper) file in other projects (or you would have more than one version of this file). IMHO not so convinient. I think it would be better to have a project/workspace management (like my extentension for VS Code has ;-) ).
Yes, definitely. I understand plouf's proposal now but this is tricky to implement because obviously the main file has to be parsed first but if there was something like @MAINFILE, the parser would have to stop parsing the current file and then restart parsing in the main file etc. Sounds like a lot of work for little gain so it's probably not worth the hassle. Maybe just use an IDE that has project/workspace management like Clydos' extension for VS Code :)

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: @MAINFILE preprocessor command

Post by plouf »

why cant a "Helper" file is not possible in my case ?
and need no more "mainfiles"

the @MAINFILE is for compiler and compiler ONLY management

that if compiler , compiles file1.hws and finds @MAINFILE (prefererable as the first line)
1) it will stop-abort compile everythink
2) start again compiling main.hws
3) ignore from now on every time it finds (again) @MAINFILE

this is possible to use big projects and when you only do changes in file1.hws open-execute-compile (F5)
in addition it WILL help using alternative editors since editor will usually pass
current source file, and you are going to have a project management
(project management is GOOD, but my idea is NOT preventing or creates the need of a extra single line of code to alter its behaviour)

Post Reply