Menu

Usage of the Mid Command.

Help
Mauried
2010-06-11
2013-05-30
  • Mauried

    Mauried - 2010-06-11

    Anyone know if this command works.
    According to the Docs the syntax is outstring=mid(instring,pos,len)
    which is essentially the normal usage for most basics.
    Trying to use it, and the Compiler hangs on the line.
    Or any other easy way of searching long strings for shorter strings.

     
  • Frank

    Frank - 2010-06-11

    Mid is just an empty shell function in string.h at the moment.

    There is an INSTR function which searches a source string for a find string and returns its position in the source string if its found or returns 0 if not. I haven't used it myself but it looks complete. The syntax would be foundpos = Instr(instring, findstr)

     
  • Nobody/Anonymous

    Hi Maurie,
    If you take a look at "string.h " in include/lowlevel  directory , you can see that "mid"  is an empty command . It's not yet  a GCBASIC command .On the other hand , "Instr" function cans help you .
    So, you can create a such subroutine by trying this ( I don't know if it's working ) :
    First you must define the string's length as described by Kent in  :
    http://sourceforge.net/projects/gcbasic/forums/forum/579126/topic/3563434
    by writing "lenstring=instring(0)" …
    Then , you'll find any character with instring( pos) . You just have to "dim character as string *lenstring "  : for npos= pos to …X  character(npos) =  instring(npos) . ("pos" is the first character you search ,  "pos to X"   is   "len" ,  "instring" is the string  in your "mid" command and "character(pos) to character(X)"  will be the characters you were searching for " )

    Regards
    GC

     
  • Mauried

    Mauried - 2010-06-11

    Fantastic.
    Thats what I need.
    Thanks .

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.