Welcome! Log In Create A New Profile

Advanced

character string operators + handeling strings

Posted by dappel 
dappel
character string operators + handeling strings
June 13, 2009 12:29AM
I need to exstract all bold markt numbers (see below information field) and characters to seprate strings. the catch is they can all change length.
exampel
from input
situation1 result situation1
metaal 320 metaal is string = 320
situation2 Result situation2
metaal 563525 metaal is string 563525

how can i isolate those bold changing length character/numbers and puth them in diffrent strings?i tried position buth that dossent work since positions arent know due changinges in lengt the position changes to

information field
06-12 11:02:13 Vloot beheer Spionagerapport van vriendelijk [1:137:10]

Grondstoffen op vriendelijk [[b]1:137:10[/b]] (Speler 'royos')
op 06-12 11:02:13
Metaal: 1.975.805 Kristal: 1.045.517
Deuterium: 276.956 Energie: 8.771
Vloten
Klein vrachtschip 21 Groot vrachtschip 75
Licht gevechtsschip 19 Zwaar gevechtsschip 17
Kruiser 1 Slagschip 253
Recycler 26 Spionagesonde 50
Bommenwerper 9 Zonne-energiesatelliet 117
Vernietiger 36 Interceptor 14
Verdediging
Raketlanceerder 4.000 Kleine laser 4.000
Grote laser 500 Gausskanon 170
Ionkanon 330 Plasmakanon 94
Kleine planetaire schildkoepel 1 Grote planetaire schildkoepel 1
Anti-ballistische raket 40
Gebouwen
Metaalmijn 28 Kristalmijn 24
Deuteriumfabriek 19 Zonne-energiecentrale 26
Robotfabriek 10 Nanorobotfabriek 2
Werf 10 Metaalopslag 10
Kristalopslag 7 Deuteriumtank 5
Onderzoekslab 11 Raketsilo 6
Kans op contraspionage:86%
Aanvallen

ps the bold markt numbers/characters are not from source bold markt i did that so i can give u a better idee from what i wanna do



Edited 2 time(s). Last edit at 06/13/2009 12:34AM by dappel.
Fabrice Harari
Re: character string operators + handeling strings
June 13, 2009 01:14AM
Hi...

Grondstoffen op vriendelijk [1:137:10] (Speler 'royos')
op 06-12 11:02:13
Metaal: 1.975.805 Kristal: 1.045.517
Deuterium: 276.956 Energie: 8.771

The first thing to do is to find the position of 1:137:10

So first, you find the position of the string preceding it (my hypothesis is that this string doesn' tchange). In this case, it would be
iStartPos is int
iEndPos is int
iStartPos=position(MyContent,"Grondstoffen op vriendelijk [")
then the end
iEndPos=position(MyContent,"]",iStartPos)
and you extract:
MyFirstValue is string=MyContent[[iStartPos+Length("Grondstoffen op vriendelijk [") to iEndPos-1]]

Then you do the same thing for each value

Best regards

Piet van Zanten
Re: character string operators + handeling strings
June 13, 2009 10:41AM
Hi Dappel,

Don't you have the possibility to store these values in a database instead of in text files?
That would make your programming life much easier.

Reagrds,
Piet
how can i do that cuz i only started programing windev (strings,activexelements,interface , edit controles i can handel Buth i stil dont understand what use analyse hes,how to add a pasword or how databases works let a side get the data in it.thats why i try to write the data in a .txt file or .rtf first the smal steps then the big ones smiling smiley




Edited 3 time(s). Last edit at 06/13/2009 11:48AM by dappel.
Piet van Zanten
Re: character string operators + handeling strings
June 13, 2009 01:37PM
Hi Dappel,

Using texfiles is possible of course, but it sure would pay to study on database design.
Your previous posts show that every time you have to invent a way to extract or save data.
You could use the time you spend on these string extraction issues for doing a tutorial on using data. You can read about the principals of a database on Wikipedia
If I look at your text file, you could build the following datafiles:

Speler
SP_ID: Unique identification of player
Naam: Player name

Hulpbronnen
HB_ID: Unique identification of resource
Omschr: Description of resource (gronstoffen, vloten, verdediging etc.)

Onderdelen
OD_ID: Unique identification of detail
Omschr: Description of detail (metaal, kristal, kruiser,slagschip etc.)

Inventaris //inventory
SP_ID: player link
DatumTijd: date time
HB_ID: resource link
OD_ID: detail link
Aantal: number of items

These files are linked together on the (unique) ID's.
So basically you create 4 datafiles containing labels and you put it all together in the "Inventaris" file.
A quick way to enter the data is WDmap. This way you don't have to write a data entry module.
I realize that now you're more interested in getting results in short term, but after some study in the end you'll be programming a lot faster (and less errors in your data) than you are now.

Regards,
Piet

p.s. If you should continue putting data in textfiles, try to structure it also. E.g. don't put two items on one line. (Either put ALL items of one category on one line or just one). You can use markers for each section and use extractstring to read them. Remember that extractstring can extract based on anything, so extractstring(sText,2,"Vloten") will return everything after "Vloten".
Hi,

I would use the RegularExpression functionality to find matching elements in the text.

Cheers,

Peter
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: