How about String Variables?


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    mytekcontrols's Avatar
    mytekcontrols Guest

    Question How about String Variables?

    I didn't see this one listed, and it is something that most Basics do support, but not PicBasic.

    It is rather annoying having to do stuff like this:
    Code:
    For x = 0 to 12
    LookUp x,["Hello World!"],y
    Buffer[x] = y
    Next x
    When if you had String variables, you could accomplish the same thing like this:
    Code:
    Buffer = "Hello World!"
    Now which would you rather do

    Of course this is just getting started down that long and "stringy" road (wasn't that a Beatles song?) .

    And hey! What about some of these other nice string functions (as he drools):

    <div align="center"><table width="575" cellpadding="4" cellspacing="0" border="1" bgcolor="#FFF8C7"><thead><tr><td align="center" bgcolor="#004BB0"><font color="#ffffff"><b>Function</b></font></td><td align="center" bgcolor="#004BB0"><font color="#ffffff"><b>Description</b></font></td></tr></thead><tbody><tr> <td><tt>Chr(int)</tt></td><td>Returns the ASCII character of the argument.</td></tr><tr><td><tt>InStr([start,] str1, str2)</tt></td><td>Returns the starting position of <tt>str2</tt> within <tt>str1</tt>, beginning at <tt>start</tt> if specified.</td></tr><tr><td><tt>InstrRev(str1, str2 [,start])</tt></td><td>Returns the starting position of <tt>str2</tt> within <tt>str1</tt> from the end of the string, beginning with <tt>start</tt> if specified.</td></tr><tr><td><tt>Join(list [,delimeter])</tt></td><td>Merges strings in the list, each separated by one space unless you specify a <tt>delimeter</tt> character.</td></tr><tr><td><tt>LCase(str)</tt></td><td>Returns the argument in all lowercase letters.</td></tr><tr><td><tt>Left(str, int)</tt></td><td>Returns the far-left <tt>int</tt> characters from the argument.</td></tr><tr><td><tt>Len(str)</tt></td><td>Returns the number of characters in the string. (Notice that <tt>Len()</tt> works on numeric arguments as well.)</td></tr><tr><td><tt>LTrim(str)</tt></td><td>Returns the string argument, without leading spaces.</td></tr><tr><td><tt>Mid(str, intStart [, intLen])</tt></td><td>Returns a substring of the argument, starting with the character at <tt>intStart</tt> and continuing until the entire the string is extracted or until the optional <tt>intLen</tt> characters have been extracted. <tt>Mid()</tt> is called the midstring function because it can return the middle portion of a string.</td></tr><tr><td><tt>Right(str, int)</tt></td><td>Returns the far-right <tt>int</tt> characters from the argument.</td></tr><tr><td><tt>RTrim(str)</tt></td><td>Returns the string argument, without trailing spaces.</td></tr><tr><td><tt>Str()</tt></td><td>Converts its numeric argument to a string with the numeric digits in the string.</td></tr><tr><td><tt>StrReverse(string)</tt></td><td>Returns the string argument that is completely reversed.</td></tr><tr><td><tt>UCase(str)</tt></td><td>Returns the argument in all uppercase letters.</td></tr></tbody></table></div>

    Now before someone jumps down my throat, and says something like "well this and that really isn't needed" or "you know you can write some code to simulate that". Remember this is a WISH LIST, and I like to make BIG wishes

  2. #2
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    I'm in 100% agreement...perhaps the "One" thing i hate about picbasic is the severe lack of string-handling.
    I would LOVE something as simple as a string buffer/variable to contain a value such as "Hello" etc.

    In the meantime, who out there has other solutions for storing/handling strings???

    I'm sure there's a few ways to store the string (as bytes) in the internal Ram and retrieve them as concatenated strings...

    May your WISH come true
    Marty.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I am curious about the application using a MCU where that type of string handleing would be needed?

    The serial and LCD commands can work with strings via arrays now.
    I see most people using a MCU for monitoring/control of something. Just wondering what you have in mind?
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Who would waste time with code-consuming arrays when you could use something like "Buffer = "Hello World!" as shown above.

    In recent coding i've played with, i've had the need for using 2character strings, it would seem inefficient to use several for-next arrays for only 2 characters.

    Why can't a buffer be assigned to xx-amount of ram locations and be given a name or symbol that can be called upon by name?

    Don't get me wrong, Picbasic Pro is EXCELLENT, but has a LONG way to go
    I can't believe many of the simple tasks i used to do with GWbasic 25+ years ago, still isn't supported in Picbasic....

    Marty.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gtvmarty View Post
    Don't get me wrong, Picbasic Pro is EXCELLENT, but has a LONG way to go
    I can't believe many of the simple tasks i used to do with GWbasic 25+ years ago, still isn't supported in Picbasic....

    Marty.
    Wow! I did not know that GWbasic worked with the architecture of a MCU.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jul 2008
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    U must have had the older version

    Quote Originally Posted by mackrackit View Post
    Wow! I did not know that GWbasic worked with the architecture of a MCU.

Similar Threads

  1. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 02:16
  2. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  3. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 14:36
  4. String Parsing
    By eoasap in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th February 2006, 17:20
  5. Message String Table using Readcode
    By mytekcontrols in forum Code Examples
    Replies: 2
    Last Post: - 10th July 2005, 23:17

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts