Sql string to list dialog
#1

Hi,
Recently I got stucked with this problem,
I try to take a string from sql and show it in a list dialog
So in the SQL the field is "Try\r\nthis" and is put on the "PInventoryComment[MAX_PLAYER][200][300]" var
Now knowing that \r\n would make a new line, then I try this....
Код:
i = 0;
while(mysql_retrieve_row())
{
mysql_fetch_field_row(PInventoryType[id][i],"type");
mysql_fetch_field_row(PInventoryName[id][i],"name");
mysql_fetch_field_row(PInventoryComment[id][i],"comment");
i = i + 1;
}

printf("%s",PInventoryComment[playerid][0]);
ShowPlayerDialog(playerid,4619,DIALOG_STYLE_LIST,"Letter",PInventoryComment[playerid][i],"ok","");
return 1;
What happen is that the printf return "Try\r\nthis",
but the list dialog show me "Try\r\nthis" in his first line and do not change line...

Thanks,
rt-2
Reply
#2

Bump and I added some information to my post..

Thanks
Reply
#3

Bump
Reply
#4

There is a difference between the \r\n that you retrieve from the database and the one that you create in a string in PAWN. I'm not sure if the precomiler changes it or not, but "Try\r\nThis" creating a string in PAWN is different to retrieving "Try\r\nThis" from the database. The ASCII characters are different in each of them. In example:

pawn Код:
new str[100], strx[100] = "Try\r\nThis";
mysql_fetch_row_format(str);
printf("str[0]: %d | str[1]: %d | str[2]: %d | str[3]: %d | str[4]: %d | str[5]: %d | str[6]: %d | str[7]: %d | str[8]: %d | str[9]: %d | str[10]: %d", str, str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7], str[8], str[9], str[10]);
printf("strx[0]: %d | strx[1]: %d | strx[2]: %d | strx[3]: %d | strx[4]: %d | strx[5]: %d | strx[6]: %d | strx[7]: %d | strx[8]: %d | strx[9]: %d | strx[10]: %d", strx, strx[0], strx[1], strx[2], strx[3], strx[4], strx[5], strx[6], strx[7], strx[8], strx[9], strx[10]);
This prints totally different things as it's actually printing \r\n in AScii characters rather than changing it into the newline.

Код:
[11:44:22] str[0]: 84 | str[1]: 84 | str[2]: 114 | str[3]: 121 | str[4]: 92 | str[5]: 114 | str[6]: 92 | str[7]: 110 | str[8]: 84 | str[9]: 104 | str[10]: 105
[11:44:22] strx[0]: 84 | strx[1]: 84 | strx[2]: 114 | strx[3]: 121 | strx[4]: 13 | strx[5]: 10 | strx[6]: 84 | strx[7]: 104 | strx[8]: 105 | strx[9]: 115 | strx[10]: 0
A solution for this may be using strReplace and finding "\r\n" and replacing it with "\r\n" although, I'm not fully sure that that will work either. If it doesn't try do something like this:

pawn Код:
new findstr[5];
findstr[0] = 92;
findstr[1] = 114;
findstr[2] = 92;
findstr[3] = 110;
strReplace(findstr, "\r\n", strsource, strdest);
I'm not sure if either of them will work but you could give it a try.
Reply
#5

The last solution worked just fine for me,, Thank you very much TheKiller!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)