Recent Posts

Pages: 1 ... 8 9 [10]
91
Code and examples / Re: Text search
« Last post by John on 10. May 2018, 07:12:10 »
0.007312 seconds.

That's pretty fast.

My old laptop and Script BASIC for Linux 64 bit does the *prince* patten match of warpeace.txt in about a 1/2 second which is fast enough for my needs.
92
Code and examples / Re: Text search
« Last post by jj2007 on 10. May 2018, 02:40:27 »
7312 Ás to find 2776 matches with the Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
Code: [Select]
[62993] looked at the princess. She still sat motionless with a look of
[62999] "Good-by, Princess!" said he.
[63012] "Yes, Princess," said Nicholas at last with a sad smile, "it doesn't
**[63018] Princess Mary gazed intently into his eyes with her own luminous
**[63032] princess had caught a glimpse of the man she had known and loved,
[63042] why. "Thank you, Princess," he added softly. "Sometimes it is hard."
[63044] "So that's why! That's why!" a voice whispered in Princess Mary's
[63065] "Princess, for God's sake!" he exclaimed, trying to stop her.
[63066] "Princess!"
[63079] In the winter of 1813 Nicholas married Princess Mary and moved to
[63313] and Sonya, blaming himself and commending her. He had asked Princess
[63350] same scale as under the old prince.
[63402] Ivanovich, the late prince's architect, who was living on in
[63649] when she and Countess Mary spoke of Prince Andrew (she never mentioned
[63650] him to her husband, who she imagined was jealous of Prince Andrew's
[63837] Rostovs he had received a letter from Prince Theodore, asking him to
[63962] "And have you talked everything well over with Prince Theodore?" she
[63968] he did frighten me... You've seen the princess? Is it true she's in
[64250] questions as to whether Prince Vasili had aged and whether Countess
**[64282] Nicholas and Natasha always brought him back to the health of Prince
[64297] translate things into his mother's language, "Prince Alexander
[64305] "Well, and how is Prince Alexander to blame? He is a most
[64422] Prince Theodore, and she helped him by asking how his affairs with
[64423] Prince Theodore had gone.
[64479] his brows. "Prince Theodore and all those. To encourage culture and
**[64909] right, and let there be but one banner- that of active virtue.' Prince
**[65024] Prince Andrew- and his father had neither shape nor form, but he
**[65031] Prince Andrew in the house, Nicholas never imagined him in human
93
EGSL / Re: EGSL Website
« Last post by Luposian on 09. May 2018, 08:23:42 »
Yes, I know. Since this isn't developed anymore, the website won't be updated anymore. Sooner or later it might "vanish into thin air", as Sherlock Holmes might have said ...  ;)

I ask only that the few remaining EGSL commands and their perameters for which documentation was never completed, be completed.  I would even pay you to do this.  I enjoy tinkering with EGSL and feel its a disservice to your users, to abandon it without at least completing the documentation for it's commands/parameters.  If there is source code that contains those commands and their parameters, then point them out to me and I will gladly dig through them and do the work myself.
95
Code and examples / Re: Text search
« Last post by John on 01. May 2018, 22:42:54 »
As Mike mentioned the case insensitivity can be toggled on/off anywhere during program execution with the OPTION statement.

Code: [Select]
OPEN "warpeace.txt" FOR INPUT AS 1
flen = FILELEN("warpeace.txt")
fstr = INPUT(flen, 1)
SPLITA fstr BY chr(10) to farr
lnum = 1
OPTION COMPARE sbCaseInsensitive
FOR idx = 0 to UBOUND(farr)
  IF CHOMP(farr[idx]) > "" AND farr[idx] LIKE "*PrInCe*" THEN PRINT FORMAT("%~[000000] ~", lnum), farr[idx],"\n"
  lnum += 1
NEXT


jrs@jrs-laptop:~/sb/examples/test$ tail -n 20 results.findit
[062993] looked at the princess. She still sat motionless with a look of
[062999] "Good-by, Princess!" said he.
[063012] "Yes, Princess," said Nicholas at last with a sad smile, "it doesn't
[063042] why. "Thank you, Princess," he added softly. "Sometimes it is hard."
[063044] "So that's why! That's why!" a voice whispered in Princess Mary's
[063065] "Princess, for God's sake!" he exclaimed, trying to stop her.
[063066] "Princess!"
[063079] In the winter of 1813 Nicholas married Princess Mary and moved to
[063313] and Sonya, blaming himself and commending her. He had asked Princess
[063350] same scale as under the old prince.
[063402] Ivanovich, the late prince's architect, who was living on in
[063649] when she and Countess Mary spoke of Prince Andrew (she never mentioned
[063650] him to her husband, who she imagined was jealous of Prince Andrew's
[063837] Rostovs he had received a letter from Prince Theodore, asking him to
[063962] "And have you talked everything well over with Prince Theodore?" she
[063968] he did frighten me... You've seen the princess? Is it true she's in
[064250] questions as to whether Prince Vasili had aged and whether Countess
[064297] translate things into his mother's language, "Prince Alexander
[064305] "Well, and how is Prince Alexander to blame? He is a most
[064479] his brows. "Prince Theodore and all those. To encourage culture and
jrs@jrs-laptop:~/sb/examples/test$

96
Code and examples / Re: Text search
« Last post by John on 01. May 2018, 22:12:37 »
Quote
Results do not match nicely what I see above; apparently, there are different versions of W+P around.

Here is what I'm using.
97
Code and examples / Re: Text search
« Last post by jj2007 on 01. May 2018, 19:33:19 »
If there were any Crown-Princes/Princesses in the text, they would also be counted in.

OK, no problem - first version is restricted to case-sensitive full word, second one is "root":
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
  Init
  Dim match$() ; for the results
  Recall "War and Peace.txt", wp$()

  NanoTimer()
  For_ ct=0 To wp$(?)-1
.if Instr_(wp$(ct), "Prince", 4) ; case-sensitive, full word (no prince, no Princess...)
Let match$(esi)=Str$("[%000i]\t", ct)+wp$(ct)
inc esi
.endif
  Next
  PrintLine NanoTimer$(), Str$(" to find %i matches with the ", esi), Cpu$()
  For_ ct=match$(?)-15 To match$(?)-1
PrintLine match$(ct)
  Next

  NanoTimer()
  xor esi, esi
  For_ ct=0 To wp$(?)-1
.if Instr_(wp$(ct), "prince", 1) ; case-insensitive (prince, Prince, Princess...)
Let match$(esi)=Str$("[%000i]\t", ct)+wp$(ct)
inc esi
.endif
  Next
  PrintLine CrLf$, NanoTimer$(), Str$(" to find %i matches with the ", esi), Cpu$()
  For_ ct=match$(?)-15 To match$(?)-1
PrintLine match$(ct)
  Next
EndOfCode
Code: [Select]
5211 Ás to find 1559 matches with the Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
[60565] from it, the death of Prince Andrew, Natasha's despair, Petya's death,
[61426] Prince Andrew (she never mentioned him to her husband, who she imagined
[61427] was jealous of Prince Andrew's memory), or on the rare occasions when
[61605] he had received a letter from Prince Theodore, asking him to come to
[61722] "And have you talked everything well over with Prince Theodore?" she
[61996] habit, and Pierre answered the countess' questions as to whether Prince
[62028] health of Prince Ivan and Countess Mary Alexeevna.
[62042] things into his mother's language, "Prince Alexander Golitsyn has
[62049] "Well, and how is Prince Alexander to blame? He is a most estimable man.
[62162] which he had gone to Petersburg to consult with his new friend Prince
[62163] Theodore, and she helped him by asking how his affairs with Prince
[62217] brows. "Prince Theodore and all those. To encourage culture and
[62624] one banner--that of active virtue.' Prince Sergey is a fine fellow and
[62734] Prince Andrew--and his father had neither shape nor form, but he
[62740] "My father!" he thought. (Though there were two good portraits of Prince

6095 Ás to find 2770 matches with the Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
[61426] Prince Andrew (she never mentioned him to her husband, who she imagined
[61427] was jealous of Prince Andrew's memory), or on the rare occasions when
[61605] he had received a letter from Prince Theodore, asking him to come to
[61722] "And have you talked everything well over with Prince Theodore?" she
[61728] frighten me... You've seen the princess? Is it true she's in love with
[61996] habit, and Pierre answered the countess' questions as to whether Prince
[62028] health of Prince Ivan and Countess Mary Alexeevna.
[62042] things into his mother's language, "Prince Alexander Golitsyn has
[62049] "Well, and how is Prince Alexander to blame? He is a most estimable man.
[62162] which he had gone to Petersburg to consult with his new friend Prince
[62163] Theodore, and she helped him by asking how his affairs with Prince
[62217] brows. "Prince Theodore and all those. To encourage culture and
[62624] one banner--that of active virtue.' Prince Sergey is a fine fellow and
[62734] Prince Andrew--and his father had neither shape nor form, but he
[62740] "My father!" he thought. (Though there were two good portraits of Prince

Results do not match nicely what I see above; apparently, there are different versions of W+P around.
98
Code and examples / Re: Text search
« Last post by Mike Lobanovsky on 01. May 2018, 19:13:25 »
John's is a show-off of SB pattern matching facilities. The code explicitly allows Prince to be searched for as "the root of the word":
Quote from: John
... LIKE "*Prince*" ...

If there were any Crown-Princes/Princesses in the text, they would also be counted in. Naturally, SB supports INSTR/INSTREV functions as well. Case sensitivity is controlled via Option Compare metastatement.
99
Code and examples / Re: Text search
« Last post by jj2007 on 01. May 2018, 18:44:46 »
include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  NanoTimer()
  Open "O", #1, "results.txt"
  Recall "War and Peace.txt", wp$()
  For_ ct=0 To wp$(?)-1
        .if Instr_(wp$(ct), "Prince", 4)        ; case-sensitive, full word (no prince, no Princess...)
                PrintLine #1, Str$("[%000i\t]", ct), wp$(ct)
        .endif
  Next
  Inkey NanoTimer$()
EndOfCode


15ms, 1579 matches:
Code: [Select]
[62028] health of Prince Ivan and Countess Mary Alexeevna.
[62042] things into his mother's language, "Prince Alexander Golitsyn has
[62049] "Well, and how is Prince Alexander to blame? He is a most estimable man.
[62162] which he had gone to Petersburg to consult with his new friend Prince
[62163] Theodore, and she helped him by asking how his affairs with Prince
[62217] brows. "Prince Theodore and all those. To encourage culture and
[62624] one banner--that of active virtue.' Prince Sergey is a fine fellow and
[62734] Prince Andrew--and his father had neither shape nor form, but he
[62740] "My father!" he thought. (Though there were two good portraits of Prince
100
Code and examples / Re: String Concatenate
« Last post by Mike Lobanovsky on 01. May 2018, 18:19:54 »
In a mature pointer aware BASIC dialect like PB, doing string concatenation in a loop would be a really bad naive idea. Use a large preallocated string/byte buffer and fill it with content keeping track of chunk "head" and "tail" pointers, and redim preserve/realloc the buffer to double its size just once or twice if it appears too small for whatever reason. Avoid excessive time-costly memory reallocation inherent in "atomic" string concatenation.

Alternatively, use PB's stock "string builder" that implements the above technique OOTB.

Still better yet, ask Hutch (or JJ) how to re-implement it in raw inline assembler to fit your immediate needs to achieve the maximum speed possible.

Dartmouth BASIC partisans will however have to resort to String$/Mid$ in a hope that their particular dialect authors were smart enough to implement the in-place Mid$ statement without the undue memory reallocation step where possible.
Pages: 1 ... 8 9 [10]