Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 8 Jahren, 3 Monaten
Letzter Beitrag:
vor 8 Jahren, 3 Monaten
Beteiligte Autoren:
dappel, Fabrice Harari, Ola

How to manipulate a string

Startbeitrag von dappel am 07.06.2009 15:30

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?

Antworten:

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

von Ola - am 07.06.2009 16:30
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



von Fabrice Harari - am 07.06.2009 17:23
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




von dappel - am 07.06.2009 18:45
found the problem thx for helping

von dappel - am 07.06.2009 19:00
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.