Dynamically generated AHK files have limit of maximum number of characters? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 22 Sep 2023, 06:44

It seems that my dynamically generated AHK temp file has a limit of ~17750 signs - after surpassing of which my main script when executed will produce pop-up message saying

Code: Select all

Error: Continuation section too long.
with specifying which line has a following it content causing this

Is there a way to get rid of this limitation; other than: [as I reckon] splitting the dynamic code into two parts, dumping the first one into this AHK temp file of mine, ordering the other part to add itself to this file and then execute that temp?

Rohwedder
Posts: 7733
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by Rohwedder » 22 Sep 2023, 10:23

Hallo,
the subscript ~.ahk is created from two parts (two continuation sections):

Code: Select all

#Requires AutoHotkey v1.1.33
FileDelete, ~.ahk
Process, Exist
FileAppend, 
(
Process, WaitClose, %ErrorLevel%
ExitApp
q::SoundBeep 4000, 20

), ~.ahk, UTF-8 ; subscript part 1
; All continuation sections except the last need a blank line at the end.
FileAppend, 
(
w::SoundBeep 1000, 20
), ~.ahk, UTF-8 ; subscript part 2
Run, ~.ahk
e::ExitApp ; Ends main and subscript

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 23 Sep 2023, 02:50

I am having a trouble with understanding how this is suppose to work, because such test fusing structure of that file of mine that sprung this topic with your solution

Code: Select all

Name_Of_The_Temporary_File := "Exceeding_DCG_Length_Limitation_Test.ahk"

FileRecycle, %Name_Of_The_Temporary_File%

Code_For_The_Temporary_File =
(
1::a
; All continuation sections except the last one need a blank line at the end

), %Code_For_The_Temporary_File%, %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
2::b
; All continuation sections except the last one need a blank line at the end

), %Code_For_The_Temporary_File%, %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
3::c

q::ExitApp
), %Code_For_The_Temporary_File%, %Name_Of_The_Temporary_File%, UTF-8

FileAppend, %Code_For_The_Temporary_File%, *%Name_Of_The_Temporary_File%, UTF-8

Run, %Name_Of_The_Temporary_File%
creates Exceeding_DCG_Length_Limitation_Test.ahk file with content

Code: Select all

1::a
; All continuation sections except the last one need a blank line at the end
, , Exceeding_DCG_Length_Limitation_Test.ahk, UTF-8
instead of expected by me

Code: Select all

1::a
; All continuation sections except the last one need a blank line at their end
2::b
; All continuation sections except the last one need a blank line at their end
3::c

q::ExitApp

Rohwedder
Posts: 7733
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by Rohwedder » 23 Sep 2023, 03:04

Then,
try:

Code: Select all

Name_Of_The_Temporary_File := "Exceeding_DCG_Length_Limitation_Test.ahk"
FileRecycle, %Name_Of_The_Temporary_File%
FileAppend,
(
1::a
; All continuation sections except the last one need a blank line at the end

), %Name_Of_The_Temporary_File%, UTF-8
FileAppend,
(
2::b
; All continuation sections except the last one need a blank line at the end

), %Name_Of_The_Temporary_File%, UTF-8
FileAppend,
(
3::c

q::ExitApp
), %Name_Of_The_Temporary_File%, UTF-8
Run, %Name_Of_The_Temporary_File%

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 23 Sep 2023, 04:11

The temp file is now generated correctly and its intended code works - but that temp AHK now does not get removed when it is closed, despite me adding the #Persistent to the main file; i.e.:

Code: Select all

#Persistent

Name_Of_The_Temporary_File := "Exceeding_DCG_Length_Limitation_Test.ahk"

FileRecycle, %Name_Of_The_Temporary_File%

FileAppend,
(
1::a
; All continuation sections except the last one need a blank line at the end - i.e. leave the below line empty

), %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
2::b
; All continuation sections except the last one need a blank line at the end - i.e. leave the below line empty

), %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
3::c

q::ExitApp
), %Name_Of_The_Temporary_File%, UTF-8

Run, %Name_Of_The_Temporary_File%

[And also: its section allows for somewhat lower number of signs than ~17000 [in comparison to expected ~17500] - but that is an insignificant issue, as this method apparently allows for adding whatever number of appended sections is needed]

Rohwedder
Posts: 7733
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Dynamically generated AHK files have limit of maximum number of characters?  Topic is solved

Post by Rohwedder » 23 Sep 2023, 04:46

Then try:

Code: Select all

Name_Of_The_Temporary_File := "Exceeding_DCG_Length_Limitation_Test.ahk"

FileRecycle, %Name_Of_The_Temporary_File%

FileAppend,
(
FileRecycle, %Name_Of_The_Temporary_File%
1::a
; All continuation sections except the last one need a blank line at the end - i.e. leave the below line empty

), %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
2::b
; All continuation sections except the last one need a blank line at the end - i.e. leave the below line empty

), %Name_Of_The_Temporary_File%, UTF-8

FileAppend,
(
3::c

q::ExitApp
), %Name_Of_The_Temporary_File%, UTF-8

Run, %Name_Of_The_Temporary_File%

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 23 Sep 2023, 07:36

It seems that you have made a mistake of pasting in the previous version as this is the exact same code as in your previous answer

Rohwedder
Posts: 7733
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by Rohwedder » 23 Sep 2023, 08:47

No. The difference is, as soon as the subscript starts it removes its own file.

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 23 Sep 2023, 11:42

Yes, you are right, my mistake; it works now, so thank you

But what is interesting is that in my main script that this FileAppend, method for my real [i.e. not this test one] dynamically generated code does not require usage od FileRecycle, %Name_Of_The_Temporary_File% its first line in order for the whole shebang to work

Rohwedder
Posts: 7733
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by Rohwedder » 24 Sep 2023, 02:34

True! But I do not recommend to remove this command.
If during a change of the dynamically generated code a pre run error (e.g. a syntax error) happens, the written subscript file does not delete itself and with the next attempt the FileAppend doubles the code.

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Dynamically generated AHK files have limit of maximum number of characters?

Post by A Keymaker » 24 Sep 2023, 04:46

But that probability seems to be taken care of with that FileRecycle, %Name_Of_The_Temporary_File% that is before the first ( that is present also in the above tests i.e. in the main file that governs creation of the temp subscript. It has not failed me for weeks now of using and tweaking that main script and this dynamic subscript

Post Reply

Return to “Ask for Help (v1)”