Results 1 to 3 of 3

Thread: Strings and data type

  1. #1

    Question Strings and data type

    Hello, There

    Im currently learning ThinBasic and i wanted to know how to do somthing. If anyone can help it would be greatly appricated. Please find attached my current code with comments, error is on line 12 with comments to indicate what i wan't it to do, i need help with the syntax of that part of my code. If anyone can please help me to get it working.

    Dim Counter           As Long
    Dim CompareValue      As String 
    Dim Sip As String
    Dim SipID As String * 3  ' Set Length to 3 This is the start value '
    Sip = InputBox$ "Name", "Input", "BoB" ' This takes input and then counts value of howmany characters the input is' 
    For Counter = 1 To Len(Sip)   
    CompareValue = Counter
    SipID = InputBox$ "Name", "Input", "ID" ' Here i want to take the second input and limit it to the number entered before by SIP eg. bob = 3 '
    SipID = As String * (CompareValue) ' Here i can't set the value to the length of SIP count"       
      MsgBox 0, CompareValue 
      MsgBox 0, SipID
    Please note, the input box for SIPID will be removed and the variable SIPID will only be used to set the string size from input SIP

    Thank you!

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Milan - Italy
    Blog Entries
    Rep Power
    Hi Henry.

    Fixed strings cannot change they initial size.
    Once you have defined your string being 3 bytes in length, it will remain such for the duration of the variable scope.
    SipID = As String * (CompareValue)
    is not a valid thinBasic syntax.

    Using fixed string length is usually driven by specific needs, maybe related to record structure or UDT structure or databases or whatever situation where you MUST be sure your string never will be greater or less that that size.

    For all other situations just use dynamic strings and all the memory handling will be done by thinBasic engine.
    You can always check your string using the many native thinBasic string functions

    Let me know.
    Eros | |
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3

    Cool Thanks

    Thank you i understand Im working on it now, think i might have found another method. That was very helpful thank you very much.

    Ill keep you posted once i have a working code!


Similar Threads

  1. FreeBasic SDK: extended data type
    By ErosOlmi in forum Module SDK (Freebasic version)
    Replies: 29
    Last Post: 15-09-2008, 20:47
  2. Most efficient integer data type for small numbers?
    By Randall in forum thinBasic General
    Replies: 4
    Last Post: 12-09-2007, 03:57

Tags for this Thread

Posting Permissions

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