Author Topic: Error on stringutil.inc?  (Read 385 times)

0 Members and 1 Guest are viewing this topic.

Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Error on stringutil.inc?
« on: June 16, 2022, 09:03:52 AM »
Hi Charles,
I'm having trouble with this little program.
Specifically I got this error: UNIDENTIFIED OPERAND: GETWORD...

Code: [Select]
'ReadSpecificLine.o2bas
uses stringutil
new Textarray t
t.load "dati.txt"
print t.line 7
print t.lineCount
del t

Ciao

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #1 on: June 16, 2022, 10:43:53 AM »
Hi Nicola,

There is a dependency here. Try uses ParseUtil instead of StringUtil.

Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Re: Error on stringutil.inc?
« Reply #2 on: June 16, 2022, 11:04:23 AM »
Thanks Charles.
OK with PARSEUTIL.INC works correctly.
Anyway I wanted to tell you that the example I took from "ROSETTA CODE" ...
Maybe it needs to be corrected?



p.s.
I really appreciate your skills and knowledge.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #3 on: June 18, 2022, 06:08:12 PM »
Thanks Nicola,

I will fix this dependency by moving the StructuredText class from StringUtil.inc to ParseUtil.inc

Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Re: Error on stringutil.inc?
« Reply #4 on: June 23, 2022, 12:00:25 PM »
Please, Charles,
could you tell me what are the "external" functions of PARSEUTIL.INC?
I would like to know them and include them in the HELP.
Ciao

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #5 on: June 26, 2022, 01:08:17 AM »
Hi Nicola,

I'm reviewing ParseUtil.inc and I have removed if few functions which have never been used. The others are used directly or indirectly by Oxide, Co2 and LeanLisp. In the longer term, Parseutil may become merged with Oxygen's source code parsers: lexa.inc and lexi.inc.

I am also interested in developing a standard for embedded documentation from which html pages can be automatically generated, like Doxygen:

https://en.wikipedia.org/wiki/Doxygen
https://www.doxygen.nl/index.html

Code: [Select]
A typical Doxygen layout looks like this:
/**
<A short one line description>

<Longer description>
<May span multiple lines or paragraphs as needed>

@param  Description of method's or function's input parameter
@param  ...
@return Description of the return value
*/

I will post Parseutil as soon a I have completed the review.




Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Re: Error on stringutil.inc?
« Reply #6 on: June 26, 2022, 09:23:17 AM »
Hi Charles,
excellent idea of ​​using Doxygen. I read something from the link you entered.
In this way the source file would have all the notes necessary to explain it and, at the same time, could be used to create its part in the HELP.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #7 on: June 27, 2022, 01:11:14 PM »
Here is a sample: - playing with markup styles

function instrword(string s,k) as int

  to find whole words in a string

  Parameters:
  s is the string to be searched
  k is the keyword to be located in s

  Return:
 the index of the first position of k in s

  if the search fails then the return value is 0


function instrword(string s,k) as int
=====================================
/**
  to find whole words in a string

  @param s is the string to be searched
  @param k is the keyword to be located in s
  @return the index of the first position of k in s

  if the search fails then the return value is 0
**/

int  lk=len k
int ,lb,rb
byte b at strptr(s)
if not k then return 0
int i=1
do
  i=instr(i,s,k)
  if i=0
    return 0
  endif
  lb=i-1
  rb=i+lk
  if b[ rb ]<48
    if i=1
      return 1
    elseif b[ lb ]<48
      return i
    endif
  endif
  i+=lk
loop
end function
« Last Edit: June 27, 2022, 03:23:25 PM by Charles Pegge »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #8 on: June 28, 2022, 02:33:15 PM »
Hi Nicola,

A reviewed and annotated ParseUtil.inc:

Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Re: Error on stringutil.inc?
« Reply #9 on: June 28, 2022, 04:55:57 PM »
Great thing Charles,
but perhaps a broad revision is needed?
Unfortunately, doing a test I get an error.

Code: [Select]
use parseutil.inc
string s="Hi Charles"

print getword(s,2)

Anyway, the program description is great that way.
« Last Edit: June 28, 2022, 05:09:03 PM by Nicola_Piano »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Error on stringutil.inc?
« Reply #10 on: June 28, 2022, 05:33:11 PM »
Ah yes, I cleaned up StringUtil.inc. Some of it was to solve a Rosetta code task but it was too specific for library code.