Page 1 of 2
annoying invisible problems
Posted: 14 Jun 2011 03:00
by CodeLobster
first post here.
two simple questions and a wish:
1. when writing a script how do I match a pilcrow at the end of a list so i can do what I want with it? it appears as a dot on xy scripting debug, doesnt match crlf and i need to get a clean report using gettoken and crlf as a separator but not at the and of a list
2. why when copying from text window (using the text script command) the copied text keeps the formatting whilst copying from respective variable doesnt?
and my wish is: the script command writefile could have the ability to prepend (?) analog to append. actually i can emulate the same result using readfile/writefile but due to the nature of my script this is not an option as it must produce a log before it reloads itself again
thank you and have a good day!
Re: annoying invisible problems
Posted: 14 Jun 2011 18:54
by CodeLobster
i was expecting to see at least an answer here but life goes on.
any way i found a solution for problem nr 1, yet to say whether or not itll fit all situations:
tip 1: chr(13).chr(10) = pilcrow.
replace("$sourceWithPilcrows", chr(13).chr(10), "|"); // ->> or any other separator
tip 2: erasing it:
$wrd = (pilcrow)Word;
$wrd = substr("$wrd", 2, ); // ->> pilcrow is a double-byte char, so substr("$wrd", 1, ); would match the 1st char only
a word on problem 2 is still welcome as whether or not i should expect for the wish come true.
Re: annoying invisible problems
Posted: 14 Jun 2011 19:43
by admin
Tip: use <crlf> for chr(13).chr(10).
Re: annoying invisible problems
Posted: 14 Jun 2011 20:00
by CodeLobster
admin wrote:Tip: use <crlf> for chr(13).chr(10).
hello, thanks for answering!
i want to match the pilcrow for a search&replacement and it seems i can't do it correctly unless i use chr(13).chr(10).
to leave some notes i did further tests produce varying results
$test = chr(13).chr(10); echo quote ($test); // ->> ["] . [<crlf>] . ["]
$test = chr(13).chr(10); echo quote $test; // ->> "quote" (written word)
$test = chr(13).chr(10); echo $test; // ->> pilcrow on debug window, "blank" on echo
$test = "chr(13).chr(10)"; echo "test" . "$test" . "test2" . '$test' . "test 3";// ->> testchr(13).chr(10)test2$testtest 3
echo chr(13).chr(10); // ->> pilcrow on debug window, as expected "blank" on echo
echo chr(10).chr(13); // ->> two dots on debug window, as expected "blank" on echo
Re: annoying invisible problems
Posted: 14 Jun 2011 20:19
by admin
Too abstract. What's your real problem? Post real code.
Re: annoying invisible problems
Posted: 14 Jun 2011 21:24
by CodeLobster
for exporting count reports for instance
select a file and execute this
Code: Select all
focus; #101; echo gettoken("<clipboard>", "count", "<crlf>");
count is 1; then select 2 files in list and the count is 3 instead of 2.
i had many problems in the recent past with this and im trying to locate code i wrote to get more exemples.
an option would be matching the last pilcrow generated by #101 then replacing it by "" but i can't so i have to rely on artificial solutions using substr.
it's so abstract ill try to report later with more accurate samples.
Re: annoying invisible problems
Posted: 14 Jun 2011 21:41
by TheQwerty
You could use RegexReplace:
Code: Select all
RegexReplace("<clipboard>", "<crlf>+$");
Re: annoying invisible problems
Posted: 14 Jun 2011 22:08
by CodeLobster
heres a good one:
Code: Select all
"Test 1"
$str1 = "John";
$str2 = "Doe
"; //forum is detecting and dealing with it as <crlf> so im not sure it will do as a good example
$str3 = "Strange";
$fin = "$str1 $str2 $str3";
step;
$blank = substr("$fin", 8, 1);
//none of the folowing will match the blank char at $str2 "Doe[blank]"
// $pilcrow = chr(13).chr(10);
// $pilcrow = "chr(13).chr(10)";
$pilcrow = ""; //despite NOT matching it continues operation!
// $pilcrow = " ";
// $pilcrow = "<crlf>";
IF ($blank == $pilcrow) { $fin2 = substr("$fin", 8, 1); replace $fin, $fin, "$fin2", ""; //why continued??? }
ELSEIF ($blank != $pilcrow) { $fin2 = $fin; }
echo $fin;
"Test 2"
$str1 = "John";
$str2 = "Doe
"; //forum is detecting and dealing with it as <crlf> so im not sure it will do as a good example
$str3 = "Strange";
$fin = "$str1 $str2 $str3";
step;
$blank = substr("$fin", 8, 1);
//none of the folowing will match the blank char at $str2 "Doe[blank]"
// $pilcrow = chr(13).chr(10);
// $pilcrow = "chr(13).chr(10)";
$pilcrow = "";
// $pilcrow = " ";
// $pilcrow = "<crlf>";
IF ($blank == $pilcrow)
{
$fin2 = substr("$fin", 8, 1); //
replace $fin, $fin, "$fin2", "";
}
ELSEIF ($blank != $pilcrow) { $fin2 = $fin; }
echo $fin;
Re: annoying invisible problems
Posted: 14 Jun 2011 22:28
by CodeLobster
TheQwerty wrote:You could use RegexReplace:
Code: Select all
RegexReplace("<clipboard>", "<crlf>+$");
Code: Select all
focus; #101; $step = RegexReplace("<clipboard>", "<crlf>+$"); echo gettoken(" $step", "count", "<crlf>");
it did for the counting but as explained above i have problems matching the invisible (pilcrow?) char. perhaps bad syntax if so id like one to explain me whats happening on the posted samples.
any word on 2. why when copying from text window (using the text script command) to notepad the copied text keeps the formatting whilst copying from respective variable (using copytext) doesnt?
or
the affix for writefile please?
ps sent mail to support with attached sample file as forum probably screwed my sample interpreting the pilcrow. lets hope they answer. report back if they do.
Re: annoying invisible problems
Posted: 15 Jun 2011 01:35
by Stefan
I remember i had my problems with such too a few years ago, but i have no problems recently, maybe i do workarounds automatically?
- - -
Test with 9.90.1012 on XP SP3,
My test code:
Code: Select all
#101;
msg "<clipboard>" . gettoken("<clipboard>", "count", "<crlf>");
Result for one selected file:
---------------------------
XYplorer
---------------------------
E:\d\XYplorer\XYcopy.exe1
---------------------------
OK
---------------------------
Result for two selected files:
which shows in dialog as:
---------------------------
XYplorer
---------------------------
E:\d\XYplorer\XYcopy.exe
E:\d\XYplorer\XYplorer.chm
3
---------------------------
OK
---------------------------
but which adds additional lines if copied to an documents
---------------------------
XYplorer
---------------------------
E:\d\XYplorer\XYcopy.exe
E:\d\XYplorer\XYplorer.chm
3
---------------------------
OK
---------------------------
But i can't explain why.
So can you show an example code where this line break disturbs you?
Do you just want to delete the last line break if any? Or what do you want?
The same for 2.)
Do you have an simple example code to show what you mean?
AND, please don't be shy to open ONE thread for every ONE problem/question (if possible. It's hard sometimes, i know)
(BTW: thanks to JC for nee
dle and threa
d cribs)
.
Re: annoying invisible problems
Posted: 15 Jun 2011 08:14
by admin
Why not first use formatlist with "e" (remove empty items), then count.
Re: annoying invisible problems
Posted: 15 Jun 2011 17:45
by CodeLobster
admin wrote:Why not first use formatlist with "e" (remove empty items), then count.
good idea!
so that's what empty items stands for? could you provide more examples of what formatlist "e" flags? perhaps such info leads support guys to include it on help file.
stefan: i had such problems too! thats one of those things that always annoyed me.
yes i compiled a small piece of code for my use to document problems like that. in hopes that one day i have more o' them as now and then they occur.
important: greatly depends on source and as i was using these codes on offline phpbb code.
id bet they'll suffice to show my problem.
at least im not the only one buggered by this lol.
saw a user telling about this other day and gave it a try.
it shows a problem i saw sometimes in other script commands when copy-pasting from text box and directly from copytext.
luckily this very forum appears to show the same problem.
Code: Select all
"test 1 - hard way"
//readurl has a hard-on-the-eye way to do it
status "downloading...", BF0000, progress;
$text = readurl("http://www.growlforwindows.com/gfw/help/growlnotify.aspx", , 1);
text "$text";
copytext "$text";
-
"test2 - soft way"
//problem happens on certain sites but not on others!!!
$url = "http://www.xyplorer.com/xyfc/search.php?search_id=active_topics"; //has problem when pasting text from clipboard
// $url = "http://www.growlforwindows.com/gfw/help/growlnotify.aspx"; //has no such problem. why???
status "downloading...", BF0000, progress;
$url2 = readurl ("$url");
$url2 = regexreplace($url2, "<[^<]*>", "");
$url2 = replace($url2,".<crlf><crlf><crlf>"," ");
$url2 = replace($url2,"<crlf>.<crlf><crlf>"," ");
$url2 = replace($url2,"<crlf><crlf>.<crlf>"," ");
$url2 = replace($url2,"<crlf><crlf><crlf>."," ");
$back = regexreplace($url2, "<[^<]*<", "");
copytext "$back";
text "$back";
Re: annoying invisible problems
Posted: 28 Jun 2011 13:43
by CodeLobster
had this idea so someone smarter may be able to help.
first copy the "doe fin" part to clipboard then execute the script.
i have other sample of invisible char which is reported as "32" by script command
asc.
none can be matched for further replacements. please advise. :s
generally i need to match the dot (.) followed or preceded by a pilcrow as in:
".pilcrow"
"pilcrow."
Code: Select all
/*
//samples of char9, 10 and 32
"
"
*/
"Test 4"
$str1 = "John";
$str2 = "<clipboard>";
$str3 = "Strange";
$fin = "$str1 $str2 $str3";
// step;
$blank = substr("$fin", 10, 1); //this index gets the chr(32)
echo asc($blank);
step;
replace $fin, $fin, "$blank", "x";
echo $fin;
Re: annoying invisible problems
Posted: 28 Jun 2011 15:59
by CodeLobster
updated my previous post that gives a chr32 proper sample.
a cookie for the person who successfuly replaces "pilcrow dot" or "dot pilcrow" by anything else.
thanks in advance for any idea on whats going on.
Re: annoying invisible problems
Posted: 10 Jul 2011 02:53
by CodeLobster
i really need some help here.
i teamed up with another user and we made a great script out of his original idea but again the invisible chars are on the way and we cant rename files when they show up their ugly invisible faces.
so any ideas on how to match the chars posted below for further replacemnt when its found?
on a prior post theres a mini test script that may give an idea.
Code: Select all
/*
//samples of char9, 10 and 32
"
"
*/