Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Nicola_Piano on June 16, 2022, 09:03:52 AM

Title: Error on stringutil.inc?
Post by: Nicola_Piano 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...


'ReadSpecificLine.o2bas
uses stringutil
new Textarray t
t.load "dati.txt"
print t.line 7
print t.lineCount
del t


Ciao
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge on June 16, 2022, 10:43:53 AM
Hi Nicola,

There is a dependency here. Try uses ParseUtil instead of StringUtil.
Title: Re: Error on stringutil.inc?
Post by: Nicola_Piano 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.
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge 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
Title: Re: Error on stringutil.inc?
Post by: Nicola_Piano 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
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge 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


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.



Title: Re: Error on stringutil.inc?
Post by: Nicola_Piano 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.
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge 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
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge on June 28, 2022, 02:33:15 PM
Hi Nicola,

A reviewed and annotated ParseUtil.inc:
Title: Re: Error on stringutil.inc?
Post by: Nicola_Piano 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.

use parseutil.inc
string s="Hi Charles"

print getword(s,2)


Anyway, the program description is great that way.
Title: Re: Error on stringutil.inc?
Post by: Charles Pegge 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.