1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Maximum length for a variable

Discussion in 'Support' started by CarlM, Feb 29, 2016.

  1. CarlM

    Joined:
    Jan 16, 2009
    Messages:
    45
    Likes Received:
    0
    My program to reformat text files reads the entire fire into a variable. Program works fine, but when it hit a file that was 8,773 bytes, TCC gave up the ghost. (Windows reported it; TCC was already dead.)
    I have a work around, but am curious what is the maximum size for a variable? Can it be increased to, say 11 KB?
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,029
    Likes Received:
    84
    TCC has no limit (other than available memory) for variables or input lines (at least for v17 or later). However, many Windows APIs have maximum size limits for their arguments. Without an example of what you're doing, I can't guess what limit you're running up against.
     
  3. CarlM

    Joined:
    Jan 16, 2009
    Messages:
    45
    Likes Received:
    0
    Thanks. I dug into it and it was @Xreplace that failed. When I changed all my Xreplace to Rereplace, everything worked. :-)
    I'll post a note to the Plugins forum.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,066
    Likes Received:
    30
    What limit (apparently ~32K) am I running into when I do this (and TCC disappears)? It would seem there's a limit on what a variable function can return.
    Code:
    v:\> unset zz
    
    v:\> do i=1 to 9000 ( set zz=%[zz]0 )
    
    v:\> echo %@rereplace[0,1111,%zz]
     
  5. CarlM

    Joined:
    Jan 16, 2009
    Messages:
    45
    Likes Received:
    0
    Vince, your test was not as fatal as mine - with yours, TCC restarted. With mine, it never came back. ;-)
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,066
    Likes Received:
    30
    It didn't restart. It just disappeared ... process ended ... no messages from windows ... no exception log.
     
  7. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,029
    Likes Received:
    84
    What you're running into is the Windows 32K limit on filenames. And @REREPLACE is intended for filename substitution & calls Windows APIs (where the crash is occurring).

    @REREPLACE is the wrong solution for this problem. TPIPE is intended for processing files; @REREPLACE is intended for processing filenames.
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,066
    Likes Received:
    30
    What is the size of the pszArguments buffer for a plugin variable or variable function? The "Plugins" help page says 2K but I'm pretty sure it's more than that these days.
     
  9. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,029
    Likes Received:
    84
    32K characters. There's no particular reason why it can't be made bigger, though as I said before any filename bigger than that will blow up Windows.
     

Share This Page