TSE: Why should one use SetBufferStr() | SetBufferStr() versus SetGlobalStr() | GetGlobalStr() ?

14 views
Skip to first unread message

knud van eeden

unread,
Mar 16, 2023, 9:32:59 AM3/16/23
to SemWare TSE Pro Text Editor
Hello,

1. An example:

PROC Main()
 INTEGER bufferI = 0
 PushPosition()
 bufferI = CreateTempBuffer()
 PopPosition()
 SetBufferStr( "a", "10", bufferI )
 GotoBufferId( bufferI ) Warn( "Press any key" )
 Warn( GetBufferStr( "a", bufferI ) )
 GotoBufferId( bufferI ) Warn( "Press any key" )
END

2. Not much to see in that buffer thus, probably hidden. 

3. Why should one use SetBufferStr() | SetBufferStr() versus SetGlobalStr() | GetGlobalStr() ?

4. Any use cases where there is a clear advantage?

5. E.g. Carlo used {Set|Get}Buffer{Str|Int} in his Huffmann implementation.

6. Otherwise SetGlobalStr() and or GetGlobalStr() can do the job as well???

7. In other words, why do {Set|Get}Buffer{Str|Int} exist, they must have some special function in TSE, otherwise they
   are just some duplicate | similar functions.

Thanks
with friendly greetings
Knud van Eeden

knud van eeden

unread,
Mar 16, 2023, 9:42:58 AM3/16/23
to SemWare TSE Pro Text Editor
So I thought now why not ask it ChatGPT:

Response was:

In Semware TSE SAL why whould one use SetBufferStr() or SetBufferStr() versus instead SetGlobalStr() GetGlobalStr() ?

In Semware TSE SAL, SetBufferStr() and GetBufferStr() are used to manipulate strings that are stored in a specific buffer, while SetGlobalStr() and GetGlobalStr() are used to manipulate global strings.

The main difference between these two approaches is scope. A buffer-based string is only accessible within the context of the buffer it is stored in, while a global string can be accessed from anywhere in the program.

When working with strings that only need to be used within a specific buffer, it is more efficient to use SetBufferStr() and GetBufferStr() to manipulate them. This is because buffer-based strings are stored in a more compact and efficient way, and their scope is limited, so they don't require the overhead of a global string.

On the other hand, if you need to share a string between multiple buffers or processes, or if you need to persist a string between invocations of the program, you should use SetGlobalStr() and GetGlobalStr() to manipulate the string.

In conclusion, it depends on the specific requirements of your program as to which approach you should use. If you only need to manipulate a string within a specific buffer, use SetBufferStr() and GetBufferStr(). If you need to share a string between multiple buffers or persist a string between invocations of the program, use SetGlobalStr() and GetGlobalStr().





knud van eeden

unread,
Mar 16, 2023, 10:04:14 AM3/16/23
to SemWare TSE Pro Text Editor
'Local' {Get|Set}Buffer{Str|Int} versus global {Get|Set}Global{Str|Int}:

One can thus use a variable with the **same** name (e.g. "a"), by using 2 different buffers (e.g. buffer1I and buffer2I).

--- cut here: begin --------------------------------------------------
 PROC Main()
  //
  INTEGER buffer1I = 0
  INTEGER buffer2I = 0
  //
  PushPosition()
  buffer1I = CreateTempBuffer()
  PopPosition()
  //
  PushPosition()
  buffer2I = CreateTempBuffer()
  PopPosition()
  //
  SetBufferStr( "a", "10", buffer1I ) // same variable name "a" but different bufferid
  SetBufferStr( "a", "20", buffer2I ) // same variable name "a" but different bufferid
  //
  Warn( GetBufferStr( "a", buffer1I ) ) // shows 10
  Warn( GetBufferStr( "a", buffer2I ) ) // shows 20
  //
 END
--- cut here: end ----------------------------------------------------



--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/semware/264061527.972269.1678974173859%40mail.yahoo.com.

Carlo Hogeveen

unread,
Mar 16, 2023, 10:34:15 AM3/16/23
to sem...@googlegroups.com

When a macro uses SetGlobalStr(string_name, value), its string_name parameter is global in the way that it might clash with another macro that also uses SetGlobalStr() using the same string_name parameter.

When a macro uses SetBufferStr(string_name, value, buffer_id), it can create its own buffer specifically for the purpose to make it impossible for string_name parameters to clash across macros.

"Buffer strings" are not stored in the buffer, but in memory attached to the buffer.

Carlo



knud van eeden

unread,
Mar 17, 2023, 5:53:46 PM3/17/23
to SemWare TSE Pro Text Editor
"
In Semware TSE SAL, SetBufferStr() and GetBufferStr() are used to manipulate strings that are stored in a specific buffer, while SetGlobalStr() and GetGlobalStr() are used to manipulate global strings.
The main difference between these two approaches is scope. A buffer-based string is only accessible within the context of the buffer it is stored in, while a global string can be accessed from anywhere in the program.

When working with strings that only need to be used within a specific buffer, it is more efficient to use SetBufferStr() and GetBufferStr() to manipulate them. This is because buffer-based strings are stored in a more compact and efficient way, and their scope is limited, so they don't require the overhead of a global string.

On the other hand, if you need to share a string between multiple buffers or processes, or if you need to persist a string between invocations of the program, you should use SetGlobalStr() and GetGlobalStr() to manipulate the string.

In conclusion, it depends on the specific requirements of your program as to which approach you should use. If you only need to manipulate a string within a specific buffer, use SetBufferStr() and GetBufferStr(). If you need to share a string between multiple buffers or persist a string between invocations of the program, use SetGlobalStr() and GetGlobalStr().

"

So just to emphasize, I checked all over the place for definitions
(in my knowledge bases, 
 in all the latest TSE source code,
 in the latest TSE read.me,
 in emails back to the year 2000 and up in my email client,
 ...
)

So basically no information out of the box.

Then instead this ChatGPT program comes back with a very accurate and logical description
which it very probably quite obviously could not just copy from text somewhere or anywhere on the Internet, 
it also uses the right definitions for those TSE keywords 
and gives the correct differences.

This is thus quite something altogether is the final conclusion.

FYIO: See e.g. this demonstration about GPT-4 just released by OpenAI

Note: I am mainly interested in applying it to TSE, and it seems thus that
'Legacy GPT-3.5' is the better choice over 'GPT-4' at the moment (possible to choose 
from in the paid version ($20 per month)). 
So I will stick to that for now, maybe GPT-4 improves over time thus.

with friendly greetings
Knud van Eeden

===

knud van eeden

unread,
Mar 17, 2023, 7:10:03 PM3/17/23
to SemWare TSE Pro Text Editor
Of course also the TSE help was searched in.
And searching on Google.
...

===

It is kind of that it can generate information out of 'no' information.

That is quite contrary to what the average us is capable of.

---

Here a short history:

For this kind of problems:

-In 1943 Warren McCulloch started to use the neuron when trying to model the brain. He used giant squids neurons as model (so it was easy to see what was inside and what happened).

-He worked together with Walter Pitts (expert in frog eyes) and also Norbert Wiener (the father of Kybernetics or control theory).
John von Neumann (one of the scientific geniuses) gave some times additional advice.

-So then the perceptron came along, but e.g. Seymour Papert (the father of the Logo computer language) showed it had severe restrictions.
So AI work stalled for many years as a result.

-Then around 2010 they started to study the (multi-layer) function of cat's eyes (e.g. implementations by Geoffrey Hinton) to get better insight in how the cat recognizes objects. So they developed as a result deep learning. So image recognition improved significantly.

-So getting input neurons, several layers of middle neurons and output neurons. One trains by putting information on the input neurons and wanting to get the wanted output on the output neurons. The parameters are here the interconnections between the neurons. Different methods are used.

-Then around 2016 Google made breakthroughs regarding natural language translation. They started to use the word2vec method to create vectors which could be used to predict the most likely next word, given an input of given words. That improved the translation between the about 100 languages that Google supports significantly. https://translate.google.com
It clusters the most likely words together as a result (e.g. queen, king, prince, duke, ... would be words clustered together and to choose from).

-Based on that 'predict next word' together with not choosing the most probable word (because that would lead to repetition), but
instead a random word out of the possible next words models like GPT, GPT-2, GPT-3, GPT-3.5 and now GPT-4 came along.

-It is based on language translation, e.g. english to english translation, e.g. english to image translation, predicting the next word, choosing a random highly probable next word. The grammar and syntax of the English language is automatically deduced from all those billions of example read from the Internet and books. It has automatically deduced e.g. the Aristotle logic rules (syllogism, ...) and so on. 

-Knowing all this it is still difficult for most to understand why it gives the good and sometimes incredible results one is witnessing. Unexpected emergence thus.

The latest achievements of GPT-4 about doing the different exams. It gets closer and closer to being the best in that fields.

Inline image


* See also the demonstration video here where it one can use his telephone to describe the visual world around itself.

* generating automatically the source code (JavaScript and HTML) directly from the written text on a piece of paper,
taken photo off and pasted into ChatGPT.


Inline image

 Inline image

Reply all
Reply to author
Forward
0 new messages