Welcome! Log In Create A New Profile

Advanced

How to manipulate a string

Posted by dappel 
dappel
How to manipulate a string
June 07, 2009 05:30PM
so far i have a edit control config as (txt) and this codes

for saving

s1 is string
nIdFil is int

// Open the file
nIdFil = fOpen("D:\peter\stop.txt", foCreateIfNotExist+foReadWrite)
IF nIdFil=-1 THEN
Error("Unable to open file", ErrorInfo())
END
s1= "tag" + EDT_Edit1
fWriteLine( nIdFil,s1 + ">")

//result of code above = a string saved with content "Tag "+ editcontrol +">"
exampel =tagwindev is nice>
now i need to know how i can read/manypilate so only the info between tag and> gets read
i woot use cursor positions buth i cant because space between Tag and> needs to be a variabel

any idee how i can make this work?
Ola
Re: How to manipulate a string
June 07, 2009 06:30PM
Hi dappel

//Not tested, but should go something like this:

//First you read the line into a variable like WholeLine
//WholeLine holds the whole line that you have read

//Then you check where the ">" is situated in the line
// -- I assume here that there is only one ">" in the line...
Endpos is int = position(WholeLine,">",1,FromEnd) - 1

//Then you can check for the length of the tag name
NetLength is int = Endpos - 3 //3 is the length of "Tag"
//use 4 if there is a space as in your question, like "Tag "

//ControlString will hold the control tag name only
ControlString is string = middle(WholeLine,4,NetLength)
//Use 5 in lieu of 4 as starting position, if there is the space...

//Maybe there are easier ways, but I always do things the hard way:-)

//regards
//Ola



Edited 1 time(s). Last edit at 06/07/2009 06:39PM by Ola.
Fabrice Harari
Re: How to manipulate a string
June 07, 2009 07:23PM
Hi

I'm not sure what you are trying to achieve here, but just in case, you should perhaps look at iniread and iniwrite in the help...

If what you have to read write is less than 64 KB, than it's a much easier solution

Best regards

dappel
Re: How to manipulate a string
June 07, 2009 08:45PM
Quote
Hi

I'm not sure what you are trying to achieve here, but just in case, you should perhaps look at iniread and iniwrite in the help...

If what you have to read write is less than 64 KB, than it's a much easier solution

Best regards

64 bytes arent gonne do it

Quote
Hi dappel //Not tested, but should go something like this:

//First you read the line into a variable like WholeLine
//WholeLine holds the whole line that you have read

//Then you check where the ">" is situated in the line
// -- I assume here that there is only one ">" in the line...
Endpos is int = position(WholeLine,">",1,FromEnd) - 1

//Then you can check for the length of the tag name
NetLength is int = Endpos - 3 //3 is the length of "Tag"
//use 4 if there is a space as in your question, like "Tag "

//ControlString will hold the control tag name only
ControlString is string = middle(WholeLine,4,NetLength)
//Use 5 in lieu of 4 as starting position, if there is the space...

//Maybe there are easier ways, but I always do things the hard way:-)

//regards
//Ola


first of al thx for al your reactions and thx for helping me get started i reconfig my code
buth somthing is stil wrong it might be a detail buth cant find it

WholeLine,ControlString are strings
Endpos,NetLength,nIdFil are int


// Open the file
nIdFil = fOpen("D:\peter\stop.txt", foReadWrite)

// 
WholeLine = fReadLine(nIdFil)
Endpos = Position(WholeLine,">",1,FromEnd) - 1
NetLength = Endpos - 3 //3 is the length of "Tag" 
ControlString = Middle(WholeLine,4,NetLength)
ControlString =EDT_Edit1
source loadit from exstern text file






Edited 1 time(s). Last edit at 06/07/2009 08:47PM by dappel.
dappel
Re: How to manipulate a string
June 07, 2009 09:00PM
found the problem thx for helping
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: