About String.trim function

No problem here, and I hope I implied no critique of anyone. As @eastgate has now more succinctly explained, occasionally we get a character that looks correct to the eye but is different.

In case others wonder, these halfwidth numbers don’t map across to regex:

In the first line of text the halfwidth ‘2’ is not matched. I the second line where I have substituted the normal ‘2’ the regex matches. I’m surprised PCRE, in the current millennium, hasn’t mapped these numbers to the normal ones as both have the same informational intent.

My takeaway here is that if a match isn’t working for text that looks right, check the Unicode value of the character(s).

these halfwidth numbers don’t map across to regex

But I believe that regex will match [0-9] , where (with considerable difficulty!) I have typed the range from FULLWIDTH DIGIT ZERO to FULLWIDTH DIGITS NINE. Of course, there’s also ⓽ and ❾ and 𝟡, the latter being “mathematical double-struck digit nine.”

I mention this partly because unicode is interesting, but also because people who run into this might create an agent that looks for $Name.contains(“[0-9]”)` to pick up on note names that contain fullwidth digits…

2 Likes

Dear Dr.Mark Anderson & Eastgate,
Thank you for your explanation and precautions for UNICODE
and half-width and full-width characters.
From now on, I will be especially careful when entering these characters.
Last night, it converted for Mac OS 11.7.10 in almost the same way as ddSKK.
I installed an engine called AquaSKK.
I wonder if this will reduce typos a little?

I will change the topic,
Q01 : When I move a child file to a parent file,
quotation marks “'” appear at the beginning and end.
It remains, but when I reuse this function and move to the parent file
Replace “leading quotation mark” with “##^”,
The trailing “'” quotation mark is “deleted”
Is there a way to write it using runCommand?
Q02 : Also, $Text=collect(children,$Text).replace(“^;”,“^\n”).substr(1,-1);
If I were to improve this,
would it be possible to use replace again after .substr(1,-1)?

Yours, WAKAMATSU

Hello everyone, how are you getting on?
Thanks to this forum,
I have a deeper understanding of the functions of String.trim etc…

Using CollectChildren Text Becker R2.tbx
Assuming that it will be used with quarto, add “##” to
the beginning of the moved child file and change the parent file.
I wrote a Stamp as follows, nemed [Trim Children 3(Stamp)]
$Text=“## " + collect(children,$Text).replace(”^;“,”^\n").substr(1,-1);
For the time being, I was able to write two “##” symbols and a “blank” in “##”.
There is one thing that caught my attention.
When writing “##”, a “blank” is simply inserted after “##” using “SPC”,
When using the blank designation symbol “^”,
which is the safest way to write it?
I feel a little uneasy about simply inserting a “blank” using “SPC”.

Q01: Is $Text="## " + written as a normal description?
Q02: What precautions should be taken when setting blank characters?
Q03: What is the correct way to use the blank designation symbol “^”?

Thank you very much for your guidance.
Yours, WAKAMATSU

AquaSKK? I’m sorry I have no way to know.

When you say ‘file’ do you mean a note?

Also, where are the quotation marks occurring? My assumption is you mean they appear enclosing the title ($Name) of the child note you have promoted.

Are you moving the notes manually or via action code?

I suspect translation has altered your meaning. Without seeing the actual code code you ran, it is hard to replicate the problem.

Yes. Chained operators, i.e. successive dot operators use the output of the previous operator so:

$Text=collect(children,$Text).replace("^;","^\n").substr(1,-1);

Is the functionally the same as using:

$Text=collect(children,$Text);
$Text=$Text.replace("^;","^\n");
$Text=$Text.substr(1,-1);

So adding (chaining) a further .replace() call to the original would be possible.

Dear Dr.Mark Anderson,
I apologize for the poor writing and inaccuracy.
It was a bad writing habit of mine,writing notes as files.

Your Question 01 : Also, where are the quotation marks occurring?
A01 : I made new Note 11, which to show ["] at beggining & end of Text.
This Note made via action code [Collect Children original]Stamp.

Child files are executed using stamps.
With the below settings, the stamp changes to the addition
that I wanted, so I think this function is achieved.
$Text=“## " + collect(children,$Text).replace(”^;“,”^\n").substr(1,-1);
But, the description in the Trim Children 3 stamp
the correct way to write it is ?, or another way to describe it?
(I feel like there is an error in the way I wrote it somewhere.)
(I hope it is just speculation?)
I would be very happy if you could give me some advice.
Yours, WAKAMATSU
TBX L - CollectChildrenText Becker R2-trim.tbx (221.5 KB)
P.S
Note 10 is my Trim Children 3 Stamp example,
adding ## and 1space at the beginning of Text.

Please don’t apologise—no need at all! :slight_smile: Working via translation just sometimes takes a bit more exchange, but we are not in in a rush.

Re Question 1. Ah OK, you aren’t moving anything. The Stamp is collecting, via Action code using collect(), the $Text of all child notes and using the resulting string as the $Text of the note being stamped. So, why are the extra " (straight double quotes, Unicode 0022) are added to the start/end of the child notes’ $Text that is collected?

The answer is given if you make a child note with no Japanese text/fonts. That note’s text is collected without the ". Why the difference? When Tinderbox makes a list (i.e. List-data type) if Tinderbox detects items in the per-list-item string that might confuse parsing out list items, Tinderbox wraps that item in quotes. However, when using such quote-enclosed list items, Tinderbox is less good at detecting and removing the quote that Tinderbox added for its own internal purposes!.

So, if I use a stamp like this on ‘Note 11’:

$Text=collect(children("Note 11"),$Text).at(0);

and ask for list items #1 (list addresses are zero-based) I’d expect the text of ‘Note 9’ without the extra quotes. Sadly I still get the quotes.

The fact this hasn’t been noticed is that it only occurs when using lists and working with East Asian languages (or Japanese, et least). Not your error, but one that is hard to detect until you see it.

Hopefully (@eastgate?) Tinderbox could detect and remove the list-item-wrapper quotes it adds.

Regardless, a better way for Wakamatsu-san and others encountering the language/locale-caused issue with quotes is to do your collect a different way. So, replace this:

$Text=collect(children,$Text).replace(';','\n');

with:

$Text =;
var:list vList = collect(children,$Text);
var:string vItemText ="";
var:string vStr= "";
vList.each(anItem){
   if(anItem.beginsWith('"')){
      vItemText = anItem.substr(1,-1)+"\n";
   }else{
      vItemText = anItem+"\n";
   }
   $Text += vItemText;
}

Or if you want to strip these quotes is after flattening to a single string, use:

$Text = collect(children,$Text).replace('^"',"").replace('"$',"").replace('";"',"\n");
1 Like

I made an error in my original reply. Fixed above, but noting it here in case you have read an email notification of the post and seen the earlier, wrong, answer.

Dear Dr.Mark Anderson,
Thank you for always providing easy-to-understand and thorough explanations.
Also, in addition to the parallel description,
I would also like to thank you for providing a sample of writing in a row.
It is a big help.
I am more familiar with the notation of writing in a line.
Use this method when writing compilation instructions in a LaTeX application.
Was it because I had to write a lot?

Previously, I would have posted questions like this right away,

  • Now, I have a question.

  • Add “#” plus “blank” to the description to be listed,

  • To “write” at the “beginning of the sentence”

  • Where should I write it down to get the correct answer?

but
Thanks to the guidance I have received so far, I have developed the ability
to calmly observe things.
First, I decided to try it on my own,
If there is a problem with writing, what is the cause?
I am starting to be able to make some decisions.

$Text += vItemText;
I rewrite it as $Text += "## " + vItemText;

“Write in a row” notation
$Text = collect(children,$Text).replace(‘^"’,“”)
.replace(‘"$’,“”).replace(‘“;”’,“\n”);
In this case, before $Text = collect at the beginning
$Text = "# " + collect(children,$Text) etc…

I have confirmed both that it works if I do those.

var:list vList = , var:string vItemText , var:string vStr
However, there is still not a thorough understanding of
how to handle them.

Sincerely yours, WAKAMATSU
P.S.
Should I use String.replace or runCommand in the future?
I would like to ask you a question. I will post it
as a new topic on another occasion.

OK, var:list vList = and the other examples are simply variable declaration:

  1. declaring a variable var.
  2. declaring that variable as List-type data: var:list. If an optional data type is not declared, Tinderbox will use a default (string) type.
  3. declaring the variables name vList. That variable can re re-used within the current action and is destroyed (no clean up needed) when the action completes. Here, an ‘action’ is a rule/edict/stamp/agent action, etc.

See my article on the var operator for more detail.

For general efficiency, use an internal app feature such as String.replace() if available before using runCommand(). Indeed, the latter is essentially there to enable Tinderbox to reach out to the Unix shell to do things there that Tinderbox cannot do internally.

Dear Dr.Mark Anderson,
Thank you for the explanation about var operator.
I read a little bit in this evening, but I still can not get it into my head.

(Please forgive me for using a music analogy.)
It is similar to the process of tuning a Grand Piano,
where we have to precisely tune each string one by one accurately.
Personally, I do not dislike tuning the piano,by myself.
It takes time, but it helps to distinguish between various overtones
and obtain subtle resonances.
Creating sounds is fun.
A bad tuner will not be able to tune the Grand Piano
by picking up on these subtle sounds.
The tuning changes slightly depending on the genre of
the piece being played and the era in which it was composed.
I am looking forward to studying this in the future,
as I have a similar feeling to this area.
Yours, WAKAMATSU

I think the best way to think of a viable is like writing a number you need to remember for the immediate task onto the back of some scrap paper rather than writing in more deliberately into a notebook. When done, you can throw away the scrap paper. Had you used a notebook you might need to go and cross out the number or record that it not longer has that value. I’d give a musical analogy if I could think of one! :slight_smile:

In the example above the scrap paper is like a variable and the notepad like using an attribute. Often in a large action you might want to re-use a value that was created from other code. Rather than run that calculation multiple times, it can be useful to store the value and use the latter in the rest of the expression. Of course at the end, you have to reset the value of the attribute being used. So:

$MyList = collect(children, $SomeAttribute);
$MyList.each(anItem){
   // do stuff
};
$MyList = ;

By comparison, using a variable serves the same need but there is no clearing up to do:

var:list vList = collect(children, $SomeAttribute);
vList.each(anItem){
   // do stuff
};

If you find yourself using $MyString or $MyNumber, etc. so store values within an action, it is an indicator that a variable might be a better choice.

But, there is no requirement by the app that you use a variable instead of an attribute to save in-process values.

1 Like

There is another important consideration here. If you find yourself using $MyString, $MyNumber as a temporary placeholder for values, I’ve found that if you are not careful, this can go awry as one block of code or a template may inadvertently overwrite in $MyString what other piece is dependent on…you basically saw off the limb your standing on. Using variables protects you from this. If you find that you do need to permanently store a variable, then that is way I came up with the concept of a TBXConfig note a couple of years back, which lets you hold global values (i.e., variables) that can be simultaneously used across multiple functions.

1 Like

Dear Mr.Michael Becker,
Thank you for reminding me of the things to be careful
about regarding using $MyString, $MyNumber.
I am currently learning about var operators little by little.
Once I start to understand one item at a time,
Purpose of advice section
" You came up with the concept of a TBXConfig note. … "
While unraveling your tbx files

  • TBX L - Copy Container and Move Notes.tbx
  • TBX L - Search contact by address.tbx
  • TBX L - Search contact by address.tbx

that were previously posted on the Tinderbox Forum, I am willing to learn.
Yours, WAKAMASTU
P.S.
If you have any other tbx files that would be good
for reference, please let me know.

I’m glad that you are making progress. At this point, I have hundreds of fifes.

I’ve found that focusing don’t the outcome (immediate and long-term) is the best place to start.

It is fine to look at an example of some code. But, what I’ve found, is that if this example has little to no relevance to what I’m working on, i.e., it is more theoretical in nature to my personal context, I have a hard time retaining the method and have to repeat my learning over and over again. Whereas, if my problem is immediate and I devise a solution that addresses it and then practice that a few times, my retention rate and capability go up by multiples.

Also, as @mwra will attest, it is much easier to help teach and address someone’s specific request, “how do I do or accomplish X, Y, Z” rather than “teach me Tinderbox.”

For me, in order of priority, here is a list of TBX capabilities that one needs to learn to begin to feel mastery with Tinderbox (each step is independent and interdependent, so you will keep recycling through the list as you ratchet up your expertise; also see, Task: Analyzing Essay Structure - #6 by satikusala):

  1. Understand your objectives and outcome first (the “how” will come later)
  2. Approach with a “beginners mind,” prepare yourself to do things differently, (re)learn to think; find your comfortable place in the community, be prepared to read aTbRef, seak out mentors.
  3. Learn Attributes (and "metacognition)
  4. LearnPrototypes (esp. concept of inheritance0
  5. LearnAction Code (aka text transformation and movement)
  6. LearnTemplates (structure, includes handling media, relationship to action code)
  7. Adopt (a daily) Incremental formalization mindset and practice (esp. not getting caught up in structure and appearance, adopting automation for rigorously, large file optimization, atomic notes/idea–what I call resources–vs. intended output)
  8. Learn new languages
    • HTML
    • CSS
    • RegEx
    • Javascript
    • Unicode
  9. Seak out companion apps (e.g., DevonThink, Bookends, Zotero, Pandoc)
  10. Become familiar with generalized computing (this helps you access the command line and open source)
  11. Give back and teach.
1 Like

Dear Mr.Michael Becker,
Thank you for your words of encouragement
and for writing out the various essential points.

  1. What am I aiming for?
    This is exactly why I decided to relearn how to use Tinderbox.
  2. Learn Attributes
  3. LearnPrototypes
    These two points caught my attention,
    and I decided to start taking the course again this time.

I started using quarto with Emacs 28.2
and realized that it might be possible with Tinderbox as well.
05. LearnAction Code
The challenge of this matter began in August.
06. LearnTemplates
I haven’t managed to organize it well yet,
so I have not gotten to the point where I can process it with a template.

8 Learn new languages
◦HTML
◦ CSS
◦ RegEx
◦ Javascript
◦ Unicode
RegEx is still an area I am not good at,
but I have mastered most of the others(I believe).
When I first launched my homepage, I wrote an HTML file by hand.
I have created a music history quiz related to HyperCard for students
at a corporate training center, and I also need to have JavaScript.
It was also a necessary tool.

Q01 : What does “Unicode” here mean?

This is a question to clarify my understanding.
(Please forgive me if you feel that I am asking a rude question.)

Q02 : Is Sangha what you mean by the concept of republic in English?

Q03 : Is your intended Buddha a right enlightened person?
Does it mean “A person who has realized the truth, essence, and reality”?

(I apologize for this being a personal matter, 
but as a Zen Buddhist myself, 
    I was curious about the wording you used.)

How is it defined in Western Europe?
The reason for asking the question is 
what you are using terms that are not well understood.

In any case, I will continue to study steadily step by step.
One of the mottos that my teacher taught me as a disciple was
Pettit à prettit.
Another motto is “Observer depuis les racines!”
(C’est la maxime que j’apprécie le plus.)
Yours, WAKAMATSU

As you know, inside the digital computer everything is a number. So we need a convention that says, “the number 65 means that character A, and 66 means B. The number 32 means “a space”. Those numbers happen to be the values used in ASCII, the American Standard Code for Information Interchange, which was one of the early conventions. It had 127 different characters, which seemed adequate for English, French, and German — the priorities of the Cold War years.

Of course, there are lots of languages that need other character sets, and they developed their own codes. By the 1980s, this was a real mess.

The Unicode Standard fixed this by coming up with one comprehensive standard for everyone. It currently defines 149,813 different characters.

For a long time, the problem with defining 100,000 different characters was that they took up too much memory. Each of the 127 characters of ASCII requires 7 bits of memory. If you need to represent 149,813 distinct characters, each one takes 18 bits. People whose main concern was English liked 7 bits better than 18 bits, because that meant their disk drives could be half the size, their machines could use half the memory, and string processing could be more than twice as fast.

Unicode gets around this in a very clever way. In one approach (called UTF8), most of the 127 characters in ASCII are handled in the same way they always were. If the character code is greater then 128, we start with a signal that says “here comes a big character!” and then have some extra bytes that hold the bigger character. (This is an oversimplification, but it’s close enough). This means that English takes up only a little more space than before. Better yet, Japanese also takes up just a little more space than before. And, if you need Cherokee or Cuneiform or Tagalog, you’re all set.

1 Like

i don’t see this as a “goal”. Well, I gues it could be, but I see this as an objective that will help you achieve a goal. Are you looking to write paper? Develop an understanding about a particular topic?

For me, it is the realization that the text we see on screens is not always what we expect. For example, you have spaces and non-breaking spaces. They both visually look like a space, but they are actually structurally different and used in different contexts. I’m finding that if I understand and learn to appreciate these differences, things get easier.

In Buddhism, as you very well may know, there is the concept fo the three jewels. To follow the path of enlightenment,

It is helpful to embrace all three, as they work hand in hand.

  1. the Buddha (the yellow jewel), the teacher (all of us are Bhuddha…we can find our teachers in many places)
  2. the Dharma (the blue jewel), the teachings, and,
  3. the Sangha (the red jewel), the community

I find this framework very useful. I find Tinderbox writ large epitomizes all of the jewels.

I believe we are all Buddha have/can have the ideal of Buddhahood in us. That we have the potential to release greed, hatred, and ignorance. I have this community to be foundational to my own efforts to achieve this.

I love your maxims. :heart::heart::heart:

Dear Eastgate,

Q01 : What does “Unicode” here mean?
Thank you for your answer to this question.
What I wanted to ask with this question was not the definition of Unicode, but
What should I learn from Becker’s Unicode?
I just wanted to know what he was thinking.

Unfortunately, there are still many Japanese websites that use Shif-JIS.
I was thinking about using UTF-8 from an early stage.
This is because I won’t have any problems writing in French or German.
[If the character code is greater than 128,
the message starts with the signal “Large character is here!”]
Is this mechanism still not completely solved?
When inputting in Japanese, a single character of the alphabet is
sometimes inserted in BBEdit,
This creates a cause for misconversion in Japanese.
Yours, WAKAMATSU

Dear Mr.Michael Becker,
I am very happy that you respect Buddhism.
If everyone on earth could realize that
they are endowed with the qualities of Buddha,
One by one, the tragic events that are happening now
will disappear, and the world will become peaceful. I think.

01 : What am I aiming for?
I decided to relearn how to use Tinderbox.
This is because not long ago I was thinking about stopping using Tinderbox.
I can do almost anything I want(even Quarto) using Emacs28.2 (Spacemacs).
I did not think I had much time to spend learning about Tinderbox,
which I did not fully understand yet.
I will leave it. I do not like this situation, so I decided to try again.
This is to protect my commitment to Live now and cherish this moment.

The topic changes.
Who taught you the definition of these three treasures?
This is a very different interpretation of the Three Treasures
according to my Zen teachings.
I am surprised.
What lineage of Buddhism does the sect that uses the analogy of jewels belong to?
The Zen master I admire and want to live like him is Zen Master Hakuin.
I continue to live like that even just now.
My breathing method is based on the method introduced by Zen Master Hakuin.
Now, live this moment.(而今(にこん Ni-Konn)the present moment , Here now)
The world of music is about living in the present moment.
Please take care of your health.
Yours, WAKAMATSU
P.S
I have attached the Ni-Konn image.
ni-kon

1 Like