Jump to content

State the last line to #include


Go to solution Solved by Jos,

Recommended Posts

Posted

Is there a way to state in an #included file a line to end the #include command?

For example, I would like my file (which is #included by other files) to look like

Func Today() ; Return the current date in mm/dd/yyyy form.
        Return @MON & "/" & @MDAY & "/" & @YEAR
EndFunc   ;==>Today

#ENDINCLUDE

;Previous implementation which must not be read, otherwise we get a "Duplicate function" error.
Func Today() ; Return the current date in dd/mm/yyyy form.
        Return @MDAY & "/" & @MON & "/" & @YEAR
EndFunc   ;==> Today

 

Posted

Thanks. This is indeed what I'm currently doing. (Actually #CS at the cut-off point and #CE at the end of the file.)

I preferred a solution similar to \endinput in LaTeX. So I know the rest of the file is not read, but the editor still colors the code for me.

I also use it for ad-hoc partial runs.

Note that a #CS-#CE does not provide a definitive cut-off solution. The interpreter still reads the code after the #CS, looking for a #CE. I might encounter problems if this section also includes #CS/#CE statements.

  • Developers
Posted

Agree that a #cs - #ce could give issues when itself contains a comment block, but then you simply could use the "comment all" option in your preferred editor, adding a ";" in front of each line.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Hi @Ilan3, my suggestion is to avoid code duplications at all. For something like "I have an old and an new version of function XY" you usually would use a version control system like GIT. No need to store a old code state, functions, whatever - just commit your code state, tag it (by a good name) and it's recoverable in a easy way.

Of course, only for aspects of your single example above it could be too much, but in general you would profit by the usage of GIT a lot regarding coding.

My 2 Cents for this topic.

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...