Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Need to look look at Character instead of Strings

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2009, 05:52 PM
Junior Member
 
Join Date: Apr 2009
Posts: 12
Default Need to look look at Character instead of Strings

Hi Folks,

I listed 4 items below I'm confused on?

I borrowed the network stream code from the Chit Chat Demo...
And I have tried to figure out the way to do the following but it is not happening...

1) Problem:
I need a way to look at the network stream data I receive on a characters by character or bytes by byte basis instead of looking at the buffer as a string???

See the server I'm connecting with sends out a Username: and Password: requests that I have to reply "Write" to... It also will send .png graphic files that have to be stored in cRandom binary mode but I need to find a certain flag 'PNG' and switch over to save mode...
How do I access the data and look for a U S E R N A M E : see depending on the time tick the first time I look and search the buffer as a string I could get
U S E R.... and the next tick I look at the buffer I get N A M E :.. Hence I miss the USERNAME: That is why I'd like to sift though the receive buffer on a character by character basis...
Also the system sends extra text back that is really not necessary to view I would like to sift the return and save to a file only the important info I want...


-------Start of Code Fragment----------

MY Code in SubTICK
Sub Timer1_Tick

'Stop Timer event as we are in Timer event'
timer1.Enabled = False

'Test if Data is available from Duats Server'
If client.DataAvailable = True Then

'Got Data from Duats Server reset TimeOut'
LnkToutTmr = LnkToutMax 'Decrement Link Time Out Timer

'Since Data is available

'HelpHere I really Don't understand why I cant Parse This buffer'
'bufferbits Character by Character byte by Byte...'
'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvv'
count = stream.ReadBytes(bufferbits(),8192)
buffer = bit.BytesToString(bufferbits(),0,count)
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'

Select RcvState

'If State = 1 Look for Nam(e
Case 0
RcvState = 0

Case 1
'Since State = 1 Test if Buffer contains String name(e'
If -1 < StrIndexOf (buffer, "e:",0) Then
'Since it Does Write Access Name to Duats Sever'
txtACode.Text = AccessCode
stream.WriteBytes (stream.StringToBytes(txtACode.text & Chr(10)))

'Change State to 2 = Look For Passwor(d'
RcvState = 2
End If

------------End Code Fragment--------------

2) Problem:
I'd like to be-able to flush the Stream receive buffer etc???

3) Problem:

Could someone explain what the following items do???
'HelpHere Not Sure what this is doing but doing it'
bit.new1

'HelpHere Not sure what this does but Doing it'
client.New1

'HelpHere Not Sure what this is doing but doing it'
stream.New1(client.GetStream,False)
Reply With Quote
  #2 (permalink)  
Old 05-18-2009, 06:57 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi apstrojny2

Quote:
'HelpHere Not sure what this does but Doing it'
client.New1
I may be wrong, but I think your running before you can walk.

Do you know how to add b4p libraries to a project and access the
properties from the libraries ?
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #3 (permalink)  
Old 05-18-2009, 11:39 PM
Junior Member
 
Join Date: Apr 2009
Posts: 12
Default

Hi Taximania,
To answer your question...

[Do you know how to add b4p libraries to a project and access the
properties from the libraries ?]

I did include the network.dll, binaryfile.dll and bit.dll both for the desk top and device for this project... But to be honest I don't really know much about objects accessing properties or these dll's or why I need to initialize the object type.... And I really don't know where to get an explaination about what I'm doing... Most of the Help or Tutorials assumes the highly informed user and just seems to explains syntax... If I try to get the additional library .zips I get no access allowed not sure why... So I'm left with cutting and pasting code from examples and demos...

I'm open to any suggestions...

Andy
Newbie
Reply With Quote
  #4 (permalink)  
Old 05-19-2009, 05:21 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

1. Additional libraries are for registered paid members only.

2. B4p has a lot of built in features. 'Serial' for instance, isn't built in.

To use serial features.
Add the serial2 library, Tools /Components
and give it a name, Tools/Add Object eg: ser

Now in your application App_Start sub, you can type 'ser' and a list of serial
options will be available.

'New1' will be an option. Click it.

Your code will now read ser.New1
That is a new instance of the serial library.
All the other 'ser' options can now be used in your code.

Just for the record, serial2 also has a New2, that is
ser.New2(port as int32, BitRate as int32, parity as string, databits as int32, stopbits as single) eg:
ser.New2(1,4800,"N",8,0)

Using this option saves you 5 lines of code, eg:
ser.new1
ser.port=1
ser.BitRate=4800
ser.parity="N"
ser.databits=8
ser.stopbits=0

Lot's of other libraries may be similiar. New1, New2, New3 etc


All other libraries, Hardware, Network etc need to be added this way if
you want to use the features in that library.

Hope this helps a bit
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk

Last edited by taximania : 05-19-2009 at 05:38 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Character encoding / code pages TWELVE Questions (Windows Mobile) 10 05-29-2008 03:17 PM
ascii character problem Gale Johnson Questions (Windows Mobile) 1 05-28-2008 03:59 PM
Trim Spaces from Beginning and end of Strings BPak Questions (Windows Mobile) 21 03-24-2008 06:51 PM
possible to use a character to break off lines of code? Stellaferox Questions (Windows Mobile) 2 02-11-2008 09:41 PM
Externalization of strings for localisation Tirs Questions (Windows Mobile) 2 05-29-2007 10:19 PM


All times are GMT. The time now is 04:24 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0