TSE: GetEnvStr( "PATH" ) gives empty string if path is too long.

9 views
Skip to first unread message

knud van eeden

unread,
Feb 5, 2026, 1:25:53 PMFeb 5
to SemWare TSE Pro Text Editor, S.E. Mitchell
Hello,

TSE 4.50.19

TSE: GetEnvStr( "PATH" ) gives empty string if path is more than 255 characters long
(so starting from length and included of 256 characters you will get an empty string).

So PATH length smaller or equal to 255 works but PATH length greater than 255 gives an empty string.

Here the PATH is about 3000 characters long.

Expected maybe some error or warning message instead if greater than e.g. 255 characters, if possible.

PROC Main()
 Warn( GetEnvStr("PATH") )
END

Inline image




Jose Adriano Baltieri

unread,
Feb 5, 2026, 1:33:47 PMFeb 5
to sem...@googlegroups.com
That's pretty bad, indeed...

Because my PATH here is also very long ...

And the way I planned the macro is to test across all possible PATHs ... Mostly for include (header) files etc this is very necessary.

Any solution ? Transform the PATH tokens into an Array ? Or dump it into a hidden (and silent) buffer ?



--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/semware/415701951.729445.1770315949773%40mail.yahoo.com.


--


Grato,
Jose Adriano Baltieri

knud van eeden

unread,
Feb 5, 2026, 1:57:28 PMFeb 5
to sem...@googlegroups.com
Yes, it must (always) be dumped in a buffer.
Because the string length limit in TSE for a string is hard coded 255 characters.

Something like to begin with (that works)

PROC Main()
 Dos( "set path > foobar.txt", _DONT_PROMPT_ + _DONT_WAIT_ )
 EditFile( "foobar.txt" )
END


S.E. Mitchell

unread,
Feb 6, 2026, 6:19:02 AM (14 days ago) Feb 6
to sem...@googlegroups.com
Hi Knud,

I will consider adding a warning message when the environment string is too large.

S.E. Mitchell

unread,
Feb 6, 2026, 6:20:49 AM (14 days ago) Feb 6
to sem...@googlegroups.com
If you are just trying to search the path, you can use:
SearchPath(fn)
Which will search for a file along the PATH environment variable.
Otherwise, you'll have to do something like Knud suggested, e.g., pipe
the output into a buffer.
The new Capture() command might help also.
--

On Thu, Feb 5, 2026 at 1:33 PM Jose Adriano Baltieri <jaba...@gmail.com> wrote:
>
> That's pretty bad, indeed...
>
> Because my PATH here is also very long ...
>
> And the way I planned the macro is to test across all possible PATHs ... Mostly for include (header) files etc this is very necessary.
>
> Any solution ? Transform the PATH tokens into an Array ? Or dump it into a hidden (and silent) buffer ?
>
>
>
> On Thu, Feb 5, 2026 at 3:25 PM 'knud van eeden' via SemWare TSE Pro text editor <sem...@googlegroups.com> wrote:
>>
>> Hello,
>>
>> TSE 4.50.19
>>
>> TSE: GetEnvStr( "PATH" ) gives empty string if path is more than 255 characters long
>> (so starting from length and included of 256 characters you will get an empty string).
>>
>> So PATH length smaller or equal to 255 works but PATH length greater than 255 gives an empty string.
>>
>> Here the PATH is about 3000 characters long.
>>
>> Expected maybe some error or warning message instead if greater than e.g. 255 characters, if possible.
>>
>> PROC Main()
>> Warn( GetEnvStr("PATH") )
>> END
>>
>>
>>
>>
>>
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
>> To view this discussion visit https://groups.google.com/d/msgid/semware/415701951.729445.1770315949773%40mail.yahoo.com.
>
>
>
> --
>
>
> Grato,
> Jose Adriano Baltieri
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/semware/CAKBEyX_wTBHdg_sFDPq1i6A%2B_%3DKzy8HM8tksgyjX1bLbQBA3-w%40mail.gmail.com.

Knud van Eeden

unread,
Feb 6, 2026, 8:39:57 AM (14 days ago) Feb 6
to TSE Pro Support
Probably the best workaround would be to keep an output of the first 255 characters of the PATH but then including a warning that the result is truncated to the first 255 characters.

with friendly greetings 
Knud van Eeden 

knud van eeden

unread,
Feb 6, 2026, 8:56:55 AM (14 days ago) Feb 6
to sem...@googlegroups.com
Even better would probably be to just always return up to the first 255 characters of the PATH.

And no warning or a warning that can be suppressed.

Then the user can e.g. make sure that his most relevant directories or files are in FRONT of the PATH and within the first 255 characters thus, so that without changes in his programs TSE out of the box can still get and work with that too long PATH. 

Because the used TSE keyword GetEnvStr() indicates clearly it is about a *STRING* and that has as is very well known a hard coded length of maximum 255 characters anyhow.

Note: returning an empty string should probably not be a good workaround. Because it is ambiguous. Because a PATH not set at all gives also an empty string. But a PATH with length greater than 255 characters gives currently also an empty string. So which of these opposite options is it then? So ambiguous.

Sent from Yahoo Mail on Samsung Galaxy S24 Ultra / 1 terabyte / artificial intelligence

knud van eeden

unread,
Feb 6, 2026, 9:51:56 AM (14 days ago) Feb 6
to sem...@googlegroups.com
Similar for

In Java similar but there searching along the GetEnvStr( "CLASSPATH" )
which can also become a string longer than 255 characters.  


Sent from Yahoo Mail on Samsung Galaxy S24 Ultra / 1 terabyte / artificial intelligence

Reply all
Reply to author
Forward
0 new messages