Jump to content
IGNORED

TurbBasic - Buffer size for strings longer than 256 Bytes


Stanier

Recommended Posts

Hi - This is my first posting and so apologies if this post is out of place. Query: I am using Borland TurboBasic to process a sequential data file where the number of characters being read into a string variable is greater than 256.

According to the manual I need to change the default setting of $COM1 to $COM2 for a larger buffer size but what is the syntax for making the change in the program? The manual talks about "communications adapter 1" but what is a communications adapter? Kind regards Reg

 

Link to comment
Share on other sites

Hi - I think I may have asked the wrong question in the above post. My question should have been "What is the maximum number of characters that can be stored in a string variable? Is the default set to 256bytes and if so, how can this value be reset to a higher value?

Apologies for the confusion, I am having to feel my way into this game. Kind regards

Link to comment
Share on other sites

I used to use Turbo BASIC quite a bit in the late 80's / early 90's. Sadly, It's been a while since I've had to use it ...

 

I believe that the $COM1 and $COM2 settings are used to set the buffer size for serial port communications.

 

I don't remember there being a 256 byte limit on strings. You should be able to easily do a test. Declare one string variable with a value that is about 200 characters. Assign a second variable to be equal to the first. Then concatenate the two together (into one of the variables or a third one) then print the contents. If the result prints the entire concatenated string then there is no specific limit.

Link to comment
Share on other sites

I can't speak for TurboBasic, but some (all?) 8-bit Microsoft Basic dialects limited strings to 255 characters. If you can't solve it otherwise, consider dimensioning an array of strings, read char by char and switch to a new string variable within the array whenever the first is full. Perhaps also keep a counter of total number of characters read, so you know how many strings within the array to traverse when you use the data later on.

 

Or perhaps you can even allocate a memory area and store data directly into it instead of string variables, depending what you intend to do?

Link to comment
Share on other sites

Hi - Doing some simple checks would certainly indicate that the number of characters which can be assigned to a string variable cannot exceed 255 characters. The strange thing is that I have not seen this limit written up or explained in the texts. I will now try out the idea of setting up an array of strings.

Many thanks for the suggestion.

Link to comment
Share on other sites

  • 1 year later...

I have exactly the same problem.

The owner's handbook indeed says that the max length of a string is 32767 characters but it is not so in a Windows XP system. The book "Using Turbo Basic" says the same. The syntax for $com1 would be the line: $com1 newsize (without "=") anywhere in the code, but it does not work here.

Hope we get some help.

Link to comment
Share on other sites

I have exactly the same problem.

The owner's handbook indeed says that the max length of a string is 32767 characters but it is not so in a Windows XP system. The book "Using Turbo Basic" says the same. The syntax for $com1 would be the line: $com1 newsize (without "=") anywhere in the code, but it does not work here.

Hope we get some help.

 

The maximum length for normal string variables might be 32767 characters, but the communication buffers could be limited. It's been a long time since I have used Turbo BASIC. I do recall having a problem with communication buffer sizes. That was at least 20 years ago. Any code that I wrote would have been left with my employer and certainly long gone by now.

Link to comment
Share on other sites

Hi. As a matter of fact I am not sure the problem is in the communications. I can LINE INPUT # very long strings and PRINT # them in another text correctly. (I cannot use "," or tabs or .,.. but it is possible.) However functions like left$, right$ and mid$ do not work well and somehow distort readding the lines. Help, please!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

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