×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

String Parsing

String Parsing

String Parsing

(OP)
Hi All, I am a big Newbie both to Tek-Tips and FoxPro so be gentle!

Right, I have FoxPro 7.0, and I am reading a string of data consisting of both numbers and ascii charecter codes, from the COMM port.

I am reading the string using the MSCOMM controll. Then I am trying to split the string up like so.

The first number is the terminal ID which is easy to get:
    RFTerminalID = Left(lnTermData,1)

But then the second is an ascii code. Which should be 2 charecters long.

But I don't know how to get both chars.

As obviously the above doesn't work.
I am a previous VB programmer and would use the MID() function. Which Fox doesn't seem to have.

Any help would be great!
Thanks

RE: String Parsing

Look up the SubStr( ) command

StartAt = 2
NumofChars = 2
lcPartOfString =  SubStr(lnTermData , StartAt , NumOfChar)

or

lcPartOfString =  SubStr(lnTermData , 4, 25)
for a substring starting at char 4 for a lenght of 25

David W. Grewe
Dave@internationalbid.com

RE: String Parsing

(OP)
Thanks Dave for your reply..

Unfortunatly I can't use substr as it isn't a string..

sorry if I was vague..

I just get 0 then three squares obviusly ascii codes..

RE: String Parsing

Hi Mike,

  Can you post exactly what you're trying to parse?  Is it just a 'string' of numbers or are characters mixed in?  (maybe you're getting squares back because the font set you're using doesn't define those upper-ascii characters)?  Do the ascii codes have a definite length or do they vary (ie- 100='d', does 99='c' or 099='c')?  A couple functions to look at are
  STR(); CHR(); VAL(); SUBSTR(); and maybe PADL().

I hope that helps, otherwise, come back for more!
-- michael~

RE: String Parsing

IF you are able to use:
RFTerminalID = Left(lnTermData,1) then lnTermData must be a character string and you should be able to use all functions that manipulate character strings.

What error message do you get when you are using SUBSTR(), on your data ?

HTH,

Weedz (Wietze Veld)
My private project:www.crowncap.demon.nl\info\crwnbase
Download the CrownBase source code !!

RE: String Parsing

(OP)
*** ActiveX Control Event ***
Local lnAsco, action, lnTermData, lnbitn ;

If This.inBufferCount > 0
        lnTermData = This.input
    IF ASC(RIGHT(lntermData,1)) = 13
        lnasco = ASC(SUBSTR(lntermdata,2,1))
        RFTerminalID = Left(lnTermData,1)
        lnbitn = ASC(Substr(lnTermData,3,1))

        thisform.text2.value = lntermdata
    

        Use .\Data\dbfcomm
        Select * From dbfcomm ;
            WHERE rascii = lnAsco ;
            INTO Cursor myquery
    
        Select myquery
        Thisform.text1.Value =  Thisform.text1.Value + " " + myquery.Descriptio
        action = myquery.Command

        &action
        
        Select dbfcomm
            Use
        Select myquery
            USE
    ENDIF
ENDIF



Seemz to work now....


Apart from the fact, I don't always recieve the full string. See it's a barcode reader. From Worthdata.com

Comes with some really good example VB apps. But boss wants it doing in stinky ol' foxpro

RE: String Parsing

If it can be done in VB, it can probably be done easier in VFP!  Of course, that's only my opinion.  :)

Dave S.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close