Split string, execute function, delete split. (1 Viewer)

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Hi all,

Working on a morse code translation function for a database in access 07

I'm having a little trouble working out how to acheive the next step.

I need to be able to take the first 3 characters (from a string of morse) from a text box, send them to a variable for use in a code, and then delete them from the string.

the entire process would need to cycle until the end of the string.

I have had experiments with various commands but just can't seem to grasp how to get thos characters to somewhere useful.

ultimately I would like to be able to compare to a table, but I'll hard code it if I have to for the short term.

I'm not new to vb6/.net/vba but have had little experience in the more complex side. (eg: splitting variables/strings)

Thanks in advance for your time and assistance.
 

BrettM

just a pert, "ex" to come
Local time
Tomorrow, 01:21
Joined
Apr 30, 2008
Messages
134
How about something like...

Code:
If Len(TextBox) Mod 3 <> 0 then Exit 'Not in groups of 3
 
StrBal= TextBox
Do While Len(StrBal) > 0
   LeftBit = Left(StrBal, 3)
   'Do something with it
   StrBal= Right(StrBal, len(StrBal) - 3)
Loop
 

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Thats gracefully simple, and I will try that.

Loops are not my strong point, but no time like the present to lean.

Will post again with the results. TY muchly.
 

boblarson

Smeghead
Local time
Today, 08:21
Joined
Jan 12, 2001
Messages
32,059
Thats gracefully simple, and I will try that.

Loops are not my strong point, but no time like the present to lean.

Will post again with the results. TY muchly.
If that doesn't work - is it one long string or are there spaces between the sets?
 

BrettM

just a pert, "ex" to come
Local time
Tomorrow, 01:21
Joined
Apr 30, 2008
Messages
134
You could also do it with a For Next if you prefer...

Code:
If Len(TextBox) Mod 3 <> 0 then Exit 'Not in groups of 3
 
StrBal= TextBox
For I = 1 to Len(TextBox) step 3
   LeftBit = Mid(TextBox, i ,3)
   'Do something with it
Next I

I think I have the Mid syntax right.
 

boblarson

Smeghead
Local time
Today, 08:21
Joined
Jan 12, 2001
Messages
32,059
And if there is a space or something else between each set of 3 (which I'm assuming there is NOT), the Split function would work great. Otherwise you do have to step through capturing 3 at a time and moving on as Brett said.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:21
Joined
Sep 12, 2006
Messages
15,652
how does the letter timing behave in a string of morse. is there an endchar character after each letter grouping, or something else.

so do you want to get three morse letters, and then change them into 3 real text characters - or something different.

ie how would you distinguish


-. . ie dash dot, then dot

from say

- .. dash, then dot dot
 

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Ok, a few questions to answer here.

I have a large collection of text files generated by a radio translation program.

The choice of 3 characters is an arbitrary choice as international morse varies in length.

I do however need to analyze the data I have. There are NO spaces between each morse letter, hence the need to analyze the string.

my hope is to flag points where certain callsigns are transmitted, and this should help me to separate individual conversations.

I have some other tasks that could be solved with the same system also.

I must thank everyone for such a rapid response. I have only a few hours each night to work on this project. i should have some results tonight all the same.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:21
Joined
Sep 12, 2006
Messages
15,652
if there are no spaces beteen letters, how can you split it at all

eg, how do you know that any given dot is an E character, and not part of a different character. i dont know the morse alphabet completely, but presumably a string of dots and dashes could be split into any number of valid letter sequences, now a human operator may get a feel for this somehow, but a computer will struggle - it will be something akin to predictive text on mobile phones, but far worse i would think

when morse is sent manually how does the operator distinguish between characters?
does the operator put a tiny delay between characters - or is it really the skill of the operator that lets him pick the letters
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 16:21
Joined
Jun 16, 2000
Messages
1,954
If there are no spaces between the groups of symbols, how can you hope to make any sense of it?
A = .-
E= .
I= ..
L= .-..
N= -.
T= -

So without spaces, the morse sequence .-.. could mean L, or it could mean AI, ATT, ETI, ETEE, ENE...

After assuming the length of the first chunk of morse, the start of the remaining string might not even be the start of a character group.

Without spaces, about the only way to work out the meaning is either to calculate all possible meanings for a sequence, then compare it to a lexicon, or to start by searching for sequences representing known common words, but either of those could fail quite spectacularly in some circumstances.
 
Last edited:

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Ok to clarify a little further, the morse came from machine generated transmissions. these were remote sensing units that reported a set string of 45 characters each session.

The units used 3 letters (D, S and U) to declare detection type (D) state (S) and unit (U). these are all 3 letter combinations in morse.

by sifting out these three letters and recording it's place in the string I can the go back and manually separate out the desired sessions.

The code I intend to run involves an IF loop. eg:

If strMorse = U then
'check rest of string
end if
if strMorse = D then
'check rest of string
end if


and so on.

so long as I have a record of sessions the rest can be done manually for the short term.

the receiving software was not good for recording pauses shorter than 30ms which resulted in the garbled text files I have now.

As I cannot replicate the events that created the data, I need to find a way to split it all up. - hence the database.
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 16:21
Joined
Jun 16, 2000
Messages
1,954
But are you saying that these codes D, S and U may appear anywhere within the string?

If so, haven't you still got a problem, because, for example, you might see the sequence -.. in there and decide this is a D, when in fact it may be any of the following:

TEE
TI
NE
TE plus the left part of F, H, I, J, L, P, R, S, U, V or W
T plus the left part of F, H, S, U or V
EE preceded by the right part of A, J, K, M, O, Q, T, U, V, W, X or Y
E preceded by the right part of C, F, G, P or R
I preceded by the right part of A, J, K, M, O, Q, U, V, W, X or Y
The last part of A, J, K, M, O, Q, T, U, V, W, X or Y followed by the first two parts of F, H, S, U or V
The last two parts of C, F, G, P or R followed by the first part of F, H, I, J, L, P, R, S, U, V or W

So when you see -.. in the unbroken string, it might be a D, or it could be one of 163 other things (so statistically, it's most likely not a D at all)
 

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Ok, to elaborate further, If I were to translate a string it would read:
(I had wanted to keep this a little secret, but i'll be changing the system entirely due to my current problem)
D00007iS00008iU00009i
While there are more complex variations this would mean:
Detection type 1 (motion),
I (successfully initiated next function),
State 2 (level 2 motion on a scale of 4),
I
Unit number 3
I



As numbers are all 5 digits long , and given when they are broken into groups of three, no numbers used equate to D, S, or U.

The numbers 7,8,9, and 0 only are used to avoid misinterpretations.

The numbering system works a little like roman numerals:

00007 = 1
00008 = 2
00009 - 3
90000 = 4
00070 = 5
00080 = 6
00090 = 7
99000 = 8
00700 = 9
00800 = 10

Except for 4 and it's multiples (preceeded with 9) they just add to each other.

The need for extremely high numbers is limited, hence the issues with multiples of 4.

however if they are required one can avoid the use of multiples of 4 to achive the higher numbers.

However, keep in mind that this system is being replaced anyway. I'm planning of going to something more suitable like RTTY.

etc.


I had considered what may happen if my information was broken or not fully readable (which has happened) and designed the system to allow for errors.
 
Last edited:

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Lol,
Don't get too lost in the complexities of the data it'self.
Long story short, the data is predictable, and organised so that a group of 3 characters can seperate out what I need to do.

It's old data that just needs to be sorted.

So far I have not had much success with the above code, but I suspect I am not declaring my variables correctly.

I'll have to check over what I have when I next have a chance.
 

boblarson

Smeghead
Local time
Today, 08:21
Joined
Jan 12, 2001
Messages
32,059
If it always has the i after it, you can use the split function:

Code:
Dim varSplit As Variant

varSplit = Split([FieldName],"i")

And then you use

varSplit(0) to varSplit(UBound(varSplit)

to get the values out.
 

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
Yes, good theory, however the issue is that I'm dealing with morse.
I need to split the more characters up before I can determine the end of each segment.

The above breakdown of the data encoding system, is based on the converted morse.

Currently my data is just a garble of .._...._._..._
 

boblarson

Smeghead
Local time
Today, 08:21
Joined
Jan 12, 2001
Messages
32,059
Yes, good theory, however the issue is that I'm dealing with morse.
I need to split the more characters up before I can determine the end of each segment.

The above breakdown of the data encoding system, is based on the converted morse.

Currently my data is just a garble of .._...._._..._
Well, I'm at a loss then. Sorry...
 

Dranoweb

Registered User.
Local time
Tomorrow, 01:21
Joined
Sep 28, 2009
Messages
68
When I get home tonight (will be late) I'll thow a few things together and present what I have. It may all make a little more sense then.
 

Users who are viewing this thread

Top Bottom