Welcome!

By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

SignUp Now!

Scrput Gives error on Some line, OK on others

I have this batch file I wrote to test whether I am online, and if the connection is any good. I've been using it for years, and it's evolved over the years to be a little more elaborate than the central "ping" commands that I use to give me the result. The problem is when I am trying to print a table of the network items, lines 65 & 66 it give me errors.

C:\btm\google2.btm [65] Usage : SCRPUT [/C /U] row col [BRIght] fg ON [BRIght] bg text ─
C:\btm\google2.btm [66] Usage : SCRPUT [/C /U] row col [BRIght] fg ON [BRIght] bg text

The strange thing is when you look at the various scrput statements, they are all the same as far as I can see (excepting location, color and variables printed). I try to line them up so I can keep an eye on that. If I comment those lines out, the remainder prints out fine. Is it something funky in the gosub-ing, or...? I've written scripts using gosub like this before. See attached file
[C:\Download]ver

TCC 25.00.30 x64 Windows 10 [Version 10.0.22000.1219].

It's actually Windows 11 Pro that I installed clean. Don't know why it says Win 10.
Thanks
 

Attachments

  • google2.btm.zip
    1.2 KB · Views: 55
I think SCRPUT requires some text to display; you get that error message when there is no text.

Here's a version with some tweaks. In line 50, I'm displaying info for the actual number of adaptors in the system. Then, in your problematic lines, I've appended a couple of strong quotes, so SCRPUT will always see something, even if that "something" ultimately works out to nothing. And in line 67, I'm truncating the description to 42 characters -- one of my adaptors has a description longer than that, overwriting your border.

I've also saved it as UTF-8, since my text editor was somehow deciding your box graphics should be rendered as Korean. Dunno why. Shouldn't affect the batch's operation at all; feel free to change it back to your preferred encoding if you like.
 

Attachments

  • google2.btm
    4.4 KB · Views: 51
I reckon @IPSUBNET[] and @IPDHCP[] are returning empty strings. That will cause the SCRPUT error. Do you really have 13 adapters? This might help.

Code:
for %%L in (0,1,%@dec[%_ipadapters]) do gosub LISTADAPTERS %%L
 
Last edited:
And for some existing adapters, @IPDHCP[] (maybe others) will be an empty string. You should check that what you're trying to SCRPUT is not empty.
 
Indeed, with the changes below (first and last lines) your script runs without errors (at least here)

Code:
    for %%L in (0,1,%@dec[%_ipadapters]) do gosub LISTADAPTERS %%L
    Scrput %_row %_column     bla on bri whi %@repeat[_,122]

    goto END
:LISTADAPTERS
set out=%%L
    Scrput %_row %_column bri whi on bri whi __
    Scrput %_row 121       bri whi on bri whi Ä
::Problem Area
:: The next line is the first way I created the output; it works. You can uncomment it, and comment out the next 7 lines to see the difference
::    Scrput  %_row  3 whi on     bla %@format[03,%ADPCOUNT] %@lower[%@format[9, %@iptype[%%L]]]   %@format[-15,%@ipAddressn[%%L]]  %@format[-17,%@ipsubnet[%%L]] %@format[-15,%@ipdhcp[%%L]]     %@format[3,%@ipzoneid[%%L]]  %@ipdesc[%%L]
    Scrput  %_row  3     whi on bla %@format[03,%ADPCOUNT]
     Scrput %_row  8 bri cya on bla %@lower[%@format[9, %@iptype[%%L]]]
     Scrput %_row 19 bri gre on bla %@format[-15,%@ipAddressn[%%L]]
     Scrput %_row 36 bri yel on bla %@format[-15,%@ipsubnet[%%L]]
     if "%@ipdhcp[%%L]" NE "" Scrput %_row 51 bri gre on bla %@format[-15,%@ipdhcp[%%L]]

1674703873630.png
 
Thank you all.
@Charles Dye
I didn't know about the strong quotes; that's interesting.
@vefatica
I never knew about the empty return, but that seems strange, because on line 61 (commented out) the whole table prints out correctly with that line -- just no color. This is why I couldn't figure it out. Previously, the line worked for quite some time printing the table out, then when I got the idea to add color, I simply moved the different functions around and added what was necessary to make it work out. It's not that I have lots of adapters in the computer, I just was curious about the info that could be displayed, and experimentation, got me to that number. I haven't had time to look up all those adapters. I never knew that I should check scrput to see if it's empty; I don't ever recall having a similar problem. Guess that's one reason I'm not a programmer.
Guess I'll study what y'all did, and try to write better scripting. Thanks, again.
 
but that seems strange, because on line 61 (commented out) the whole table prints out correctly with that line
That's because you're giving SCRPUT a string which is not empty (though some of its parts are missing). Compare these two (there is no variable _garbage).

1674754518968.png
 

Similar threads

Back
Top