gononono64

[Help] Getting rid of the pesky carage returns

8 posts in this topic

#1 ·  Posted (edited)

Hey there,
Im importing some data from an sql database and trying to shove it into an .ini file. For some reason when I try to write a description of the card to the file it adds some of it to the end of the keys

Example:
[12345]
name= blahblahblah
desc= some text here which then cuts off here and
ot=6
...
finish down here

[12346]
...

Now i did try to replace @crlf with ~n~ . It did it for most of them but im still getting cases of the above and i dont know why.

Here is my code

...
Local $ptr_texts, $ptr_datas, $aDataCol, $aTxtCol
Local $aSorted[1][13] ,$aFill[1][13]

_SQLite_Query(-1, "SELECT * FROM datas", $ptr_datas)


While _SQLite_FetchData($ptr_datas, $aDataCol) = $SQLITE_OK  ; This get 1 row at a time

        $aFill[0][0] = $aDataCol[0]
        
         _SQLite_Query(-1, "SELECT name , desc FROM texts WHERE id = " & $aDataCol[0], $ptr_texts) ;pulling from seperate database to add name and desc
        If _SQLite_FetchData($ptr_texts, $aTxtCol) = $SQLITE_OK then

            $aFill[0][1] = $aTxtCol[0] ;name

            $aTxtCol[1] = StringReplace($aTxtCol[1], @CRLF, "~n~") ;replaces most of the carage returns
            $aFill[0][2] = $aTxtCol[1] ;desc
        EndIf

        $aFill[0][3] = $aDataCol[1] ;ot
        $aFill[0][4] = $aDataCol[2] ;alias
        $aFill[0][5] = $aDataCol[3] ;setcode
        $aFill[0][6] = $aDataCol[4] ;type
        $aFill[0][7] = $aDataCol[5] ;atk
        $aFill[0][8] = $aDataCol[6] ;def
        $aFill[0][9] = $aDataCol[7] ;lvl
        $aFill[0][10] = $aDataCol[8];race
        $aFill[0][11] = $aDataCol[9];attribute
        $aFill[0][12] = $aDataCol[10];catagory
        _ArrayAdd($aSorted, $aFill) ;uses $aFill and inserts into main array


WEnd

MsgBox(0,"", "finished loading from database") 



_ArraySortXD($aSorted, Default, Default, Default, 0, 1);function from a wonderful man used to sort the array via name

For $i = 0 To UBound($aSorted)-1 Step +1
        ;insert ini add file
        IniWrite ( "cards2.ini", $aSorted[$i][0], "id", $aSorted[$i][0] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "name", $aSorted[$i][1] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "desc", $aSorted[$i][2] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "ot", $aSorted[$i][3] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "alias", $aSorted[$i][4] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "setcode", $aSorted[$i][5] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "type", $aSorted[$i][6])
        IniWrite ( "cards2.ini", $aSorted[$i][0], "atk", $aSorted[$i][7] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "def", $aSorted[$i][8] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "level", $aSorted[$i][9] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "race", $aSorted[$i][10] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "attribute", $aSorted[$i][11] )
        IniWrite ( "cards2.ini", $aSorted[$i][0], "category", $aSorted[$i][12] & @CRLF )

Next

_ArrayDisplay($aSorted) ;array displays perfectly
_SQLite_Close()
...

 

Any insight as to what im screwing up, would be greatly appreciated.

Thanks in advance

Edited by gononono64

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try:

  • StringStripWs($sString, 3)
  • StringStripWs($sString, 7)
  • StringStripCR($sString)
Edited by Subz

Share this post


Link to post
Share on other sites

#3 ·  Posted

27 minutes ago, Subz said:

Try:

  • StringStripWs($sString, 3)
  • StringStripWs($sString, 7)
  • StringStripCR($sString)

 Okay im trying this:
 

$aTxtCol[1] = StringReplace($aTxtCol[1], @CRLF, "~n~")
            $aTxtCol[1] = StringStripWs($aTxtCol[1], 3)
            $aTxtCol[1] = StringStripWs($aTxtCol[1], 7)
            $aTxtCol[1] = StringStripCR($aTxtCol[1])


            $aFill[0][2] = $aTxtCol[1]

it takes a few hours so ill let ya know

Thanks for the reply

Share this post


Link to post
Share on other sites

#4 ·  Posted

Actually I meant try one of those :)  StringStripWs with Flag 3 removes any whitespace at the beginning or end of a string, StringStripWs with Flag 7 removes double spaces and whitespace at the beginning or end of a string and lastly StringStripCR removes any @CR from a string.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

yeah no go. BUT im replacing ot with $ot as well as all the other keys to see if maybe its finding words with ot in the description and placing it there

ALSO: i placed all 3 because i wanted to be safe. i figured if i added all 3 it wouldnt really hurt as the previous lines should already remove it

Edited by gononono64

Share this post


Link to post
Share on other sites

#6 ·  Posted

You could use RegEx, (although I'm not a guru with the subject) please see example below.

$sString = ""
$sString &= "The quick brown fox jumped over the lazy dog." & @CRLF
$sString &= "The quick brown fox jumped over the lazy dog." & @CR
$sString &= "The quick brown fox jumped over the lazy dog." & @LF
$sString &= "The quick brown fox jumped over the lazy dog." & @CRLF

MsgBox(0, "Original String", $sString)

$sReplace = StringRegExpReplace($sString, '\s', " ")

MsgBox(0, "Updated String", $sReplace)

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

still occasional instances likr this

98927491]
$id=98927491
$name=Ambulance Rescueroid
$desc="Rescueroid" + "Ambulanceroid"
$ot=3
$alias=0
$setcode=22
$type=97
$atk=2300
$def=1800
$level=6
$race=32
$attribute=4
$category=262144

This monster cannot be Special Summoned except by Fusion Summon. Once per turn, when a monster on your side of the field is destroyed by battle and sent to the Graveyard, you can Special Summon that monster in Defense Position.
[36378213]
...

wth is going on?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@gononono64 you have been around long enough that you should have read the forum rules by now. Please do so before you post again, especially the part about game automation, and you will see why this thread is now locked. You will not receive any help on this subject.

@gononono64 As I mentioned in our PM this thread falls into something of a gray area: threads on game interaction are permitted only if the entire game is AutoIt source. As long as this thread remains a question of database and file interaction only and doesn't devolve into automation of the game, it is fine to continue.

I will reiterate what I stated in PM as well; snide complaints directed at the Mod staff aren't going to go a long way toward helping you. We are all more than willing to discuss issues that come up and, as in this case, revisit locked topics. But the maturity with which you approach the discussion will determine the outcome as well.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now