Re: Components: How do you reuse utility code?

2017-04-21 Thread David Adams via 4D_Tech
On Sat, Apr 22, 2017 at 12:44 PM, Peter Jakobsson via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> A single developer needs to reproduce the same code over again for many
> applications. A component-based approach requires them to distill out and
> de-couple business logic so that it is explicitly addressed in areas that
it
> is only implicitly addressed in a host-only project. This leads to a
quantum
> leap in reliability as well as a huge increase in that developer’s
capacity
> for addressing complex business problems.

What you're describing are the benefits of modularity and data hiding. I'd
argue that there is no more important practical concept in everyday
programming. In 4D, it's hard as the language provides virtually no
assistance and several hinderances. If the component features have helped
you with this, that's great and I doubt that anyone would want to take that
away from you. It's just that some of us have an acquaintance with a larger
range of tools and techniques...that's why we're complaining about the
long-standing (eternal) limitations of the 4D language. So, it's probably
not that we disagree with what you think is good (encapsulation is good),
it's that we disagree that components are particularly good at it (compared
either to some ideal or with standard practice.)

I do like your point about how moving your code into components has
improved how you think about code. Yeah, that makes a lot of sense. And
that's way more  important than any little trick or twiddle with individual
lines or methods.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: components - questions about variable scope

2017-04-21 Thread Wayne Stewart via 4D_Tech
Chip,
Totally separate variable name space.
You can access variables via pointer and that's it.

Otherwise I use access methods quite a lot.  Consider this method (from a
component) to set a variable associated with a boolean:

  // Project Method: Wnd_CloseBox ({Include a close box?})  -->  Boolean

C_BOOLEAN(Wnd_CloseBox_b)
C_BOOLEAN($1;$0)

If (Count parameters=1)
  Wnd_CloseBox_b:=$1
End if
$0:=Wnd_CloseBox_b

I have lots of methods named almost identically to the variable like this
(it's easier to set up in a macro!).

I find this much easier to work with than using pointers and the coding of
it feels very similar to using a variable.

If (Wnd_CloseBox)
//  Do something
end if

or

Wnd_CloseBox(True)//  To set the variable

Note that 4D does not complain if there is a $0 value returned and not used
at all.








Regards,

Wayne


[image: --]
Wayne Stewart
[image: http://]about.me/waynestewart



On 22 April 2017 at 07:41, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> I am working on my first component -
> all the chat about them  :)
>
> process and inter process variables
> what can be seen by the component of/from the host, and vis-verse
>
> At the moment - I am looking at an inter process var in my nascent
> component,
> can the host database see this?
> if I change an IP variable value in a component does it change the host
> value?
>
> Thanks
> ---
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread Peter Jakobsson via 4D_Tech
Jim -

I read all of your post with interest. But with respect, IMHO it really does 
not do the least bit of justice to the real world applications that 4D’s 
component architecture is designed to address. Nor does it reflect the practice 
of a component based development paradigm.

For example the invocation of the ”domain specific” aspect of 4GL’s is of very 
little use practically because it doesn’t characterise 4D’s industrial context 
in any significant way. SQL has a user interface, an integrated database and a 
reporting function, but look how different it is from 4D in practice. It’s true 
that “4GL”s are a vaguely defined technological concept, but I did outline a 
specific interpretation as I saw relevant in my last post.

On 22 Apr 2017, at 00:47, James Crate via 4D_Tech <4d_tech@lists.4d.com> wrote:

> It’s difficult to imagine having 30 small independent components in a 4D 
> system, and in reality it would be unworkable because then each component 
> would need to include it’s own method to split a string to an array, or 
> descend into the problems of dependent components

Luckily, I have the benefit of not having to imagine the last 10 years of my 
professional life and the associated “descent” into the problems of dependent 
components. On the odd occasion, reality can turn out better than imagination ;)

> IMO that is one of the biggest reasons there is no significant code-sharing 
> or component community in 4D, as compared to almost any other language. There 
> would need to be a “standard library” component that other components could 
> depend on, or they all have to reinvent every wheel.


The “standard library’ you allude to already exists. It’s called the 4D 
language. The bulk of the world's 3GL “standard libraries” are trying to be the 
4D language and they never get anywhere near the level of consistency, version 
continuity or platform support that 4D does. (Otherwise I’d be using them !). 
Beyond that you’re into the business logic layer and the diversity that exists 
therein is the main reason for the lack of code sharing in the community. But 
that doesn’t mitigate the advantages of a formally implemented modular approach.

In that regard, the primary role of 4D components (in my experience) apart from 
re-useability is quality control.

A single developer needs to reproduce the same code over again for many 
applications. A component-based approach requires them to distill out and 
de-couple business logic so that it is explicitly addressed in areas that it is 
only implicitly addressed in a host-only project. This leads to a quantum leap 
in reliability as well as a huge increase in that developer’s capacity for 
addressing complex business problems.

> These are both tight coupling. This is compile-time vs runtime binding. 


Thanks very much ! That is indeed a more accurate description.

> Also, using the term “productive” is kind of amusing when primarily what 
> people would put into a component are the missing parts of the framework 
> (i.e. string trim/split, blob searching, array operations, making C_OBJECT 
> nicer to use)

Although that type of functionality is to be found in 4D component libraries, 
it doesn’t really qualify as ‘canned business logic’ which is where most of the 
benefit is to be had. A more useful (and in my experience typical) example of 
content domains might be:


FINANCIAL
 • double entry bookkeeping logic
 • multi-currency library for managing trial balances
 • dimensional analysis
 • consolidation libraries (multi-company)
 • credit control
 • period management
 • journalling properties
 • caching
 • sales tax

TRADING
 • inventory definition libraries
 • inventory registration
 • revision control
 • location and balance tracking libraries
 • property inheritance (for model-product hierarchies)
 • stock movement journalling definitions
 • trigger and stock error definition

ADDRESSING
 • address book API
 • library support for form embedding

SERVICES
 • http libraries
 • PAYPAL API clients
 • XLIFF generators
 • OAuth libraries
 • Google API clients

MARKUP
 • text processing

DOCUMENTS
 • all kinds of 4D Write wrappers and PDF production

SECURITY
 • generic logic for user logins
 • support for business logic level privileges
 • session tracking libraries
 • privilage-based form configuration support

TIME
 • period algebra libraries (second - day - week - month - year - calendar 
quarter - financial quarter)

MIGRATION
 • data migration/export import by various means (records, blobs, text etc)

UTILITIES
 • RFC support (e.g. 3986, 8601, 4217)
 • path functions (level navigation, multi-platform, joining, splitting)
 • version control
 • property bags (text, blob, object)
 • text DIFFING libraries
 • query canning (caching optimisations, counting, logic cans)
 • string functions  (this is where your string ‘trim/splt’ would go)
 • binary libraries (byte arithmetic, object opacity, colour addition, 
saturation, brightness etc)
 • CODECS
 • 

Re: Object visualize / browse

2017-04-21 Thread Douglas von Roeder via 4D_Tech
David:

"component" - yup. if I price it right, I'll corner the entire market.

Agree about the hList idea. No question that once you get past a few dozen
rows, the quick and dirty scrolling variable approach *would* get old.


--
Douglas von Roeder
949-336-2902

On Fri, Apr 21, 2017 at 6:12 PM, David Adams via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> > Sounds like a great idea for a…
>
> > component. :-)
>
> While you are clearly a bad, bad man...I look forward to your component ;-)
>
> I do really like the idea an object bound to an hlist. That would make a
> very nice feature. Hlists already have all of the gooey goodness we would
> want. It's just the binding. For which you would need complete parsers and
> a tree.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Object visualize / browse

2017-04-21 Thread David Adams via 4D_Tech
> Sounds like a great idea for a…

> component. :-)

While you are clearly a bad, bad man...I look forward to your component ;-)

I do really like the idea an object bound to an hlist. That would make a
very nice feature. Hlists already have all of the gooey goodness we would
want. It's just the binding. For which you would need complete parsers and
a tree.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Object visualize / browse

2017-04-21 Thread Douglas von Roeder via 4D_Tech
David:


No magic. Just the content of the string/Obect in a variable on the form
that you can scroll.

It's quite "straightforward" in that it displays the same data from the
Object but doesn't have the UI controls of the debugger. That would be
*quite* nice.

The work I've done to date with Objects has been with objects that I use as
structs to carry small payloads. That's quite different from inhaling reams
of data from a HTTP stream, for example.

Sounds like a great idea for a…


component. :-)


--
Douglas von Roeder
949-336-2902

On Fri, Apr 21, 2017 at 5:57 PM, David Adams via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> > If you're in V16.something, you can create a dynamic variable of type
> > Object. If  a
> > text var.
>
> It sounds like there's some magic to be had here that I haven't heard of. I
> just tried in V16 and found that setting an 'object' variable (explicit or
> dynamic) lets you display the contents of an 'object'. Basically, what you
> would get by stringifying the object and display it as text. What I don't
> see is what Justin is after, an interactive tree explorer for the JSON,
> like the Debugger has. Is there a way to get that? It would be a great
> feature. Really great. You would have hlists with close to zero hassle.
> Hey, there's an idea, bind an object to an hlist.
>
> Anyway, am I missing something that's already available?
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Object visualize / browse

2017-04-21 Thread David Adams via 4D_Tech
> If you're in V16.something, you can create a dynamic variable of type
> Object. If  text var.

It sounds like there's some magic to be had here that I haven't heard of. I
just tried in V16 and found that setting an 'object' variable (explicit or
dynamic) lets you display the contents of an 'object'. Basically, what you
would get by stringifying the object and display it as text. What I don't
see is what Justin is after, an interactive tree explorer for the JSON,
like the Debugger has. Is there a way to get that? It would be a great
feature. Really great. You would have hlists with close to zero hassle.
Hey, there's an idea, bind an object to an hlist.

Anyway, am I missing something that's already available?
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Object visualize / browse

2017-04-21 Thread David Adams via 4D_Tech
> Can anyone suggest a straightforward approach to displaying a 4D object
as a
> browsable item - something like what you see in the debugger window, only
in
> a dialog form?

It's awkward to do with native 4D commands alone because:

* There's no way to parse or navigate JSON as a tree.

* There's no way to get 4D to tell you the type of an embedded array. No
way. You can guess at embedded arrays, but it's problematic.

Alternatively, if you've got NTK available in your project, you can use the
complete JSON processing suite and do whatever you like.

Several of us have made UIs or tools for doing as you ask, so someone might
gift you some code. JPR had an example with big honking bits of code
circulating last year. He had to guess at array types, like anyone else.
But at least he did a bunch of the hard grunt of converting the
object-JSONish text-hlist, etc.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Object visualize / browse

2017-04-21 Thread Douglas von Roeder via 4D_Tech
Justin:

If you're in V16.something, you can create a dynamic variable of type
Object. If  wrote:

> Can anyone suggest a straightforward approach to displaying a 4D object as
> a
> browsable item - something like what you see in the debugger window, only
> in
> a dialog form?
>
>
>
> --
> View this message in context: http://4d.1045681.n5.nabble.
> com/Object-visualize-browse-tp5751523.html
> Sent from the 4D Tech mailing list archive at Nabble.com.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Object visualize / browse

2017-04-21 Thread Justin Leavens via 4D_Tech
Can anyone suggest a straightforward approach to displaying a 4D object as a
browsable item - something like what you see in the debugger window, only in
a dialog form?



--
View this message in context: 
http://4d.1045681.n5.nabble.com/Object-visualize-browse-tp5751523.html
Sent from the 4D Tech mailing list archive at Nabble.com.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread David Adams via 4D_Tech
Jim Crate wrote:

> Depends on what you consider 3GL vs 4GL

Yeah, I find the terms unhelpful. They aren't crisp enough to mean anything
useful without a lot of discussion about what you mean by each term first
;-)

> These are both tight coupling. This is compile-time vs runtime binding.

I'm glad that you picked up on that as I missed it. In 4D, it's very common
to see what I think should be called "pathological coupling." It's just bad
coding, regardless of language. As a contemporary point, people should
think through what they pass in messages via CALL FORM and CALL WORKER.
Ideally, the caller *does not know the details of the callee.*

CALL FORM(WindowID;"UpdateButtons")

Seems okay. The target window is asked to update it's button's states.
Presumably the window checks some data and figures out if something needs
changing. If so, it does it. But the caller doesn't know what (if anything
happened.)

CALL FORM(WindowID;"UpdateButtons";"UploadPDFButton";True)

This version tells the remote window to enable the UploadPDFButton. This is
pathological coupling. What happens if:

* You rename the button?
* You want to add more rules for what enables/disables the button? Where do
they go?
* What if you want to call the window to do an update from multiple
locations? Imagine the button flickering on and off.
* What if you get rid of that button altogether?
* What if you add a button to upload as text?

If you go with the first version, all of the logic is in the target
window's control:

CALL FORM(WindowID;"UpdateButtons")

If you go with the second approach, you've got a mess:

CALL FORM(WindowID;"UpdateButtons";"UploadPDFButton";True)


P.S: I'm going to keep offering reminders that CALL FORM and CALL WORKER
don't really send messages. I've written most of my code to make them work
like that, but it isn't what 4D's doing. What 4D is doing is

EXECUTE METHOD IN FORM WINDOW
EXECUTE METHOD IN WORKER
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread James Crate via 4D_Tech
On Apr 21, 2017, at 12:41 PM, Peter Jakobsson via 4D_Tech 
<4d_tech@lists.4d.com> wrote:
> 
> On 21 Apr 2017, at 02:44, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
>> I think we sometimes forget that 4D is not a 3GL programming language like C 
>> or C++. 4D is a 4GL language. You don’t get all the feature, benefits and 
>> capabilities of a 3GL language in a 4GL language. Remember why we all use 4D 
>> instead of using C++. You can get so much more done with 4D in less time and 
>> with less programming effort than doing it in C++.
> 
> In general, I find 4D’s component model immensely powerful - still far more 
> productive than its 3GL equivalents and there isn’t a lot I would change 
> about it.

Depends on what you consider 3GL vs 4GL, I suppose. 4D isn’t really much of a 
4GL, it’s more of a (very) stripped-down 3GL with an integrated database and 
IDE being the only 4GL features. 

Although, there isn’t really much consensus about what makes a 3GL vs 4GL. By 
the strictest definition, a 4GL is domain-specific, so regular expressions and 
SQL could be considered 4GLs, and C, ruby, and python would be 3GLs. 
Objective-C would normally (rightfully) be considered a 3GL, but since it is 
primarily used within the confines of the Xcode IDE with the trappings of 
Foundation and AppKit, it could be considered as 4GL as 4D. 

Also, using the term “productive” is kind of amusing when primarily what people 
would put into a component are the missing parts of the framework (i.e. string 
trim/split, blob searching, array operations, making C_OBJECT nicer to use).  
By comparison, the “components” (gems) I use in Ruby/Rails apps are for 
productive things like generating/expanding zip files, creating CSV files, 
creating PDFs, interacting with external programs/services (LDAP, ImageMagick, 
etc). My Mac/iOS apps so far have been small and focused, but the few 
“components” I’ve used have had laser-like focus onto a specific problem 
domain, which they can do because they do not have to implement basic language 
features.

It’s difficult to imagine having 30 small independent components in a 4D 
system, and in reality it would be unworkable because then each component would 
need to include it’s own method to split a string to an array, or descend into 
the problems of dependent components.  IMO that is one of the biggest reasons 
there is no significant code-sharing or component community in 4D, as compared 
to almost any other language. There would need to be a “standard library” 
component that other components could depend on, or they all have to reinvent 
every wheel.

The worst part is that it didn’t really have to be this way. New commands have 
been added to the language over the years, so the language lacking basic 
features isn’t necessarily because they don’t have “a language guy” or can no 
longer modify the compiler. It’s not that it is too difficult to figure out 
what a basic language framework needs; a function to split a string to an array 
exists in the standard library for every language I have used in the last 20 
years except 4D, Applescript and C/C++ (although most doing C++ would use 
Boost, which includes this). 

Also, with the speed of modern computers, interpreted code can run pretty fast, 
and if they spent some effort to make the interpreter better in the cases where 
it is slow, they may not even really need the compiler. Plenty of code runs 
every day in javascript, ruby and python and is fast enough.


> 1: Tight Coupling
> (Where a component references another component’s method explicitly). 
> Advantages: compiler is made aware of all calls, compiles as reliably as if 
> all methods were host native calls.
> 
> 2: Loose Coupling
> (Where EXECUTE METHOD is used). Advantages: components can be ‘unplugged’ 
> without any compiler complaints.

These are both tight coupling. This is compile-time vs runtime binding. 

An example of loose coupling would be one component publishing a notification 
that it did something, and another component listing for that notification to 
do something in response.  Obviously, sending a notification hoping some 
library will split your string into an array is not the right way to do things. 
Sending a notification that a file has been generated can allow another 
component to email that file to somebody, and a different component could show 
the file to the user, and the component that generated the file and published 
the notification doesn’t even need to know or care if anyone was listening.

Jim Crate

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Tom Benedict's rule engine - something that you need to know about.

2017-04-21 Thread David Adams via 4D_Tech
Tom Benedict mentioned in passing that a "rule engine" he presented at the
Summit in 2014 might be the right tool to help John Foster solve a problem.
My ears perked up because I've long wanted to have a rule engine in 4D but
haven't taken the time to write one. Tom hooked me up with the notes (I
also have direct access @ 4D, as it turns out), and I wanted to make this
resource visible to a wider range of people.

Rule engines are one of those specialized tools that it's good to know
about in advance. Just like knowing about a specialized algorithm helps you
solve a new problem, so too something like a broader technique - like a
rule engine. Before getting into any CS stuff, let me link to an easier to
understand example of a similar tool. In the life sciences, there's a handy
tool called a "dichotomous key" that's broadly used. You have a bunch of
yes-no questions that let you figure out what mushroom, weed, tree,
whatever you're seeing. Graphically, it's a decision tree that looks like
this:

Dichotomous Key of Histology
http://www.noelways.com/courses/Anatomy%20and%20Physiology%20I/Lectures_API/Lec4_Histology/Histology_Key/Dichotomous_key.html

Normally, they're used as a series of yes-no questions, like this typical
example:

Common Trees of the Pacific Northwest
https://oregonstate.edu/trees/dichotomous_key.html

A silly one shows how it works with space aliens:
https://au.pinterest.com/pin/574490496192985761/

The hard part with a dichotomous key is not using it, it's building it. You
have to know enough about the subject to come up with the right questions.
You need an expert. That's what the rules encode, expertise. Back in the
1980s, "Expert Systems" were kind of the rage. By chance, I lived with a
DB2 programmer that was *obsessed* with expert systems. That's how I even
know about them. But that kind of decision flow is a pretty old ideaan
old Greek guy used it and figured out that humans are "featherless bipeds."

Now, just for a moment, imagine how you would write a piece of code to
answer the same question. Pretend that you've got a UI that lets a person
describe a tree and figure out the species. What does the Pacific Northwest
have? 50 native species? Something like that. (Since giant sheets of ice
covered most of the region until recently, the soil there is rich but the
species diversity is incredibly low.) Anyway, if you think it through -
it's a pretty hard problem to solve. A bunch of keywords for different
features? A bunch of fields for different aspects (general shape, color,
shape of edge, etc.)? The searches are going to be hard either way. If
you've ever found yourself in this sort of coding situation, it probably
made your neck stiff ;-) Okay, so let's imagine that you sort it out -
you've nailed it all down.

Now they want to include exotic trees that are common in the area. Oh. So
now you need to include gums from Australia, some Asian maples, and so on.
Some fit pretty easily into your existing system as they're from families
you already have (maples), others don't because they're from new families
(eucalypts.) Okay, a pain, but doable.

Now they want to be able to pick between versions. One with exotics, one
without. Oh again. But your rules are likely baked into a bunch of
complicated case statements and/or complicated queries. Not easy. In fact,
when dealing with a real-world situation, it may literally be too hard to
do. Just incredibly, deeply hard. Apart from that, with the codes
implicitly encoded in fields/case of/search and combines, there isn't a way
to reuse or visualize the data. Anyone that looked at the first link above
saw a very easy to follow chart that encodes a *ton* of complex rules. You
couldn't easily produce that by reusing anything pretty much hard-coded.
So, that's bad. Rules embedded right in the code are hard to visualize,
test, validate, reuse, modify, or even understand. It's a nightmare. Many
of us have been there.

So, this is where the rule engine comes in. You can to get the rules *out
of the code and into data*. As data, the rules can be converted to a
printed table for review, converted to a chart for reuse (like the first
example post), duplicated and revised to make experiments or new
applications easy. What do you need?

ExpertiseRules Rule processor

Expertise is hard, of course. And for a real-world application, what you're
probably encoding are complicated (read "insane") government regulations,
convoluted pricing calculations, weighted prioritization factors (for
scheduling or resource allocation), drug combination outcomes, dosing
guidelines, or diagnostic guesses. Hey, those are all both complicated and
important. Exactly the sort of coding you want to get right...exactly the
sort of coding that's nearly impossible to get right with regular
techniques. So back to Tom's tool and the three things you need.

So, assuming that you are or have access to an expert, the coding parts you
need are the encoded rules and the 

components - questions about variable scope

2017-04-21 Thread Chip Scheide via 4D_Tech
I am working on my first component -
all the chat about them  :)

process and inter process variables
what can be seen by the component of/from the host, and vis-verse

At the moment - I am looking at an inter process var in my nascent 
component,
can the host database see this?
if I change an IP variable value in a component does it change the host 
value?

Thanks
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread David Adams via 4D_Tech
On Sat, Apr 22, 2017 at 2:41 AM, Peter Jakobsson via 4D_Tech <
4d_tech@lists.4d.com> wrote:

What a fantastic post! Peter, thanks so much for taking the time to share
your point of view and knowledge. This is a help to me now, and an
excellent contribution to the archives.

I've already said my piece, I'm going to try to make components work for me
a bit and see if I can live with them...so I won't qibble or comment. I am
super happy that this conversation has staid so fruitful, depsite me
throwing a trantrum! You guys are all very kind and patient ;-)

> ERROR HANDLING
> I notice David, you were having issues with this, but I think you may
have gravitated straight
> to the exception that’s the most footery aspect of components. (If you
had been eating a lobster,
> it would be like picking of one of those tiny end-claws and trying to get
the meat out of it
> rather than going for the body flesh first :-)).

Heh! Without a doubt, I have a gift. If I try out something new in 4D and
*don't* crash it within an hour, I know I'm doing something wrong ;-)
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread Tim Nevels via 4D_Tech
On Apr 21, 2017, at 2:00 PM, Peter Jakobsson wrote:

> On 21 Apr 2017, at 02:44, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
>> I think we sometimes forget that 4D is not a 3GL programming language like C 
>> or C++. 4D is a 4GL language. You don’t get all the feature, benefits and 
>> capabilities of a 3GL language in a 4GL language. Remember why we all use 4D 
>> instead of using C++. You can get so much more done with 4D in less time and 
>> with less programming effort than doing it in C++.
> 
> Amen to that ;)  What a thread !

Glad you said that. After reading David’s reply I was starting to think my 26 
years of 4D development work and my 4 year computer science degree was worth 
less than I thought it was. 

> I know this may slightly horrendous but it’s actually simpler to implement it 
> may sound as long as you do it in a “lab environment” - plain pair of vanilla 
> structures with hardly any other code in them. It has one huge advantage - 
> you only ever need 1 error handler when you’re working with lots of 
> components. After that, no need to worry about the context (in which 
> component the error occured) so one can go back to being a host developer ;)
> 
> WHAT DO WE NEED CALLBACKS FOR ?
> In 15 years of component developing, here’s a comprehensive list of the only 
> callbacks I’ve ever needed:
> 
>  - FORM GET PROPERTIES
> - Get Pointer (for both objects and fields in a (Table;Field) synta)
> - MENU BAR handling
> - GET PICTURE FROM LLIBRARY
> - ON ERR CALL

Great post Peter. We needed a component expert involved in this discussion. I’m 
not an expert like you. Component work is maybe 2% of my 4D work over the 
years. But like you said, there is a learning curve and once you get past it 
things start to clear up and makes sense. 

It reminds me of when I first started to learn 4D. I was working with a guy 
that had several years of 4D experience. He was my teacher. I was trying to do 
thing in 4D like I had learned in school programming COBOL and Pascal and was 
having trouble. He gave me this advice:

You have to learn how to do it the 4D way. Otherwise you are always swimming 
upstream. Learn how to paddle the 4D boat and you will enjoy the ride a lot 
more. And you’ll get to your destination faster. That changed things for me and 
in 6 months, with his guidance and teaching, I was loving 4D and getting a lot 
accomplished. 

You comments about callbacks is great information for everyone. Some things 
just can’t be done in the component context. You have to create host methods 
and share them and then call those methods from the component to get 
information.

In one component I created that had a UI and included a menu bar I found that 
menu bars share the same address space with the host. So if I have a menubar 
defined in the toolbox in the component with number 3 — or a name it does not 
matter — you can run into trouble. If in the component you call SET MENU BAR(3) 
— and you also have a menu bar 3 in the host — there is a conflict and the host 
menu bar 3 get possessed. Again calling it by a unique name like SET MENU 
BAR(“component menu bar”) does not make a difference because the menu bar has 
an ID of 3 in the component. Here is how to make it work:

C_TEXT($menuRef_t)
$menuRef_t:=Create menu("ISE Quick Report")
SET MENU BAR($menuRef_t)

You have to call “Create menu” from the component. I guess this creates an 
instance of the menu differently that referencing it by ID or name. Whatever is 
happening under the hood, this is how I got it to work.

> Hope that helps…and to David A.,  I hope you manage to stick with it long 
> enough to write another “Joy of Triggers” episode someday !

More likely he’ll call it “50 Shades of Components”. :)

Tim


Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread Robert McKeever via 4D_Tech
Remember subtables inside of subtables? (4D v1.xxx). Lots of fun - if used 
right.

> On Apr 21, 2017, at 8:31 AM, Keith White via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
>> If they did care, some of these things could have been added instead of 
>> querying on object fields that most people will eventually wish they didn’t 
>> use in the first place.
> 
> This made me smile a lot.I had exactly the same thought.  It brings back 
> memories of subtables which I'm sure every 4D old-timer regrets ever using, 
> if they ever did.  Someone could compile a list of 4D features with a 
> recommended "steer clear of this to avoid regret later"  ;-)
> 
> To add my 0.02p on components:-
> 
> No.  Don't like them.  Don't use them in our coding.   I'd only ever use them 
> for an essential 3rd Party "drop-in" black-box component that I have no 
> intention of amending the source code for, so much akin to plug-ins.
> 
> Other than that, I can only echo what others have said about wanting the 4D 
> language moved forward a bit.  I do recall that 4D did say at a Paris Summit 
> that they had decided to re-commit to the 4D language.  Adding 
> multi-threading support is possibly a sign of that decision, even though I 
> really dislike their implementation of it.
> 
> Best regards
> 
> Keith White
> Synergist Express Ltd, UK.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

_
Bob McKeever  http://www.mswl.com 
McKeever's Software Wizardry
Port Coquitlam, B.C.
bobmckee...@mac.com




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread Peter Jakobsson via 4D_Tech

On 21 Apr 2017, at 02:44, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> wrote:

> I think we sometimes forget that 4D is not a 3GL programming language like C 
> or C++. 4D is a 4GL language. You don’t get all the feature, benefits and 
> capabilities of a 3GL language in a 4GL language. Remember why we all use 4D 
> instead of using C++. You can get so much more done with 4D in less time and 
> with less programming effort than doing it in C++.

Amen to that ;)  What a thread !

Great discussion.

I feel I must make at least an attempt to convert David’s component-pain to 
pleasure by recontextualising some of the interpretations of the archetype. Of 
course everyone has their personal priorities and preferences so it’s just my 
take, but I have spent 30% of my living existence doing components so I’ll get 
these points of my chest before any more of it passes me by (Life that is).

In general, I find 4D’s component model immensely powerful - still far more 
productive than its 3GL equivalents and there isn’t a lot I would change about 
it. I haven’t read the whole thread but some general points that spring to mind 
are these:

FLAT vs HIERACHICAL METHOD TIERS

In my view, 3GL - 4GL distinction isn’t to do with language, it’s to do with 
complexity.

In a 4GL (well at least in 4D’s implementation) we are always working within a 
unified top language tier which is flat. It’s therefore right that the 
developer should have to disambiguate between method names amongst components 
because the whole point of the component is that it provides a seamless 
extension to the host (flat) method namespace as opposed to some kind of 
hierarchical class-based extension.

DESIGN TIME vs RUNTIME ARCHITECTURAL CONTEXT
As such, it’s not comparable with say a class library or a DLL or other type of 
3GL code module since 4D components are only given an architectural context at 
runtime. This is a huge advantage over traditional coding structures because 
when we design and build components we’re always working in a host context. 
When we’re developing a component, we should not think like a component 
developer, we should think like a host developer because 4D will do the 
architectural contextualisation for us at runtime. If you start to think 
architecture when you’re building components you’ll get very confused because 
there is no architecture at design time. There are of course odd exceptions to 
this but a tiny number and they *are* exceptions, not the rule (See “NASTY 
STUFF” section at the end of this ramble).

NAMESPACES
Remember, 4D owes much of its productivity to implicit referencing, with the 
proverbial elephant in the room being of course the datafile itself. Current 
selections are implicit (within the scope of a process), globals are, methods 
are, form scripts are, form objects are and resources are to name but a few. 
There are no explicitly referencable namespaces anywhere in the language and 
the reason there aren’t any in components is because it would significantly 
disrupt this highly productive paradigm for very little gain and probably a 
measurable productivity loss. As Tim says, it also conflicts with 4D’s identity 
as a 4GL.

CASCADING DEPENDENCIES
Contrary to some of the concerns I’ve seen expressed, you can have components 
call other components in a hierarchy without any problem. In fact you can have 
2 types of coupling in that regard:

1: Tight Coupling
(Where a component references another component’s method explicitly). 
Advantages: compiler is made aware of all calls, compiles as reliably as if all 
methods were host native calls.

2: Loose Coupling
(Where EXECUTE METHOD is used). Advantages: components can be ‘unplugged’ 
without any compiler complaints.

The optimal choice can also depend on short/long term criteria. If your 
component is going to be used all over the place and potentially only 
occasionally, loose coupling can be better. If the component is a permanent 
resident (e.g. a bookkeeping library in an ERP) then I find tight coupling far 
more reliable.

DESKTOP CONFIG: ALL AT THE SAME LEVEL
The fact that a component doesn’t "on board” its dependencies is a GOOD thing, 
not a deficiency IMO. It confines the dependency hierarchy to the logic, not 
where they happen to be located on the desktop and again reflects the 4GL 
paradigm that all components are ultimately an extension of the host top layer. 
You’d end up with a version control nightmare if you had to install the same 
component in 6 different siblings instead of just once at the host level. So 
again, my view is that 4D have thought this through to give us the best of all 
worlds:

 • We have cascading hierarchical dependency supported
 • We have optimal desktop configuration
 • We have a choice of hard or soft coupling

RESOURCES
How 4D handles these is a thing of beauty IMO and is worth including into the 
overall architectural appraisal. When I researched this for my summit 
presentation I actually blew myself 

Re: Converting Little Endian Byte Representation To a String

2017-04-21 Thread Cannon Smith via 4D_Tech
Hi Arnaud,

Interesting idea. In all actuality, even though we call the tag a “number", it 
is always treated as a string. This algorithm I needed help with was the first 
time in 10 years I needed to think of it as a number, and that was only a 
temporary step for the way the algorithm worked.

Thanks for the idea, though!

--
Cannon.Smith
Synergy Farm Solutions Inc.
Hill Spring, AB Canada
403-626-3236




> On Apr 21, 2017, at 6:29 AM, Arnaud de Montard via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> just thinking about the opposite option… 
> You store the number as a string because that number is "too big" for 4D 
> numeric fields. Now, 15 digits string means 15*2 chars in an alpha/text field 
> = 30 bytes, and not a number as a result. While a uuid field is a number, 16 
> bytes, represented by 32 chars. I'm wondering if a uuid field instead 
> wouldn't be better.  

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Methods, Components, Comments, and Tooltips

2017-04-21 Thread John DeSoi via 4D_Tech

> On Apr 21, 2017, at 9:59 AM, Chip Scheide <4d_o...@pghrepository.org> wrote:
> 
> What does this project method look like?
> 
> Case of
> :(form event=)
>  case of
>   :(Last object = )
> do stuff


Example below. All calls to Form event in the database are replaced with a 
wrapper FM_Form_event. Same for current object/focus object commands.

So execution of an object method sets up the form context and then executes 
this method with the object name. No need to make every object method call a 
project method or maintain the code below -- it is automatically generated from 
the form.



John DeSoi, Ph.D.





  // Auto generated by DVT_Generate_form_test_method.

  //$1 - Form object name.

C_TEXT($1)

Case of 
: ($1="Field16")
  LINK1_Table (->[Company];FM_Object_self ;->[Label]Company_ID)

: ($1="Button4")
  ESCROW_UPDATE (->[Label]Escrow_Min_Threshold;True)

: ($1="BUTTON3")
  UI_OPEN_URL ([Label]URL)

: ($1="Invisible Button4")
  UI_Table_input_view (->[Company];[Label]Company_ID)

: ($1="BUTTON2")
  UI_OPEN_URL ([Label]Email;"")
End case 

DV_FORM_EVENT 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread Keith White via 4D_Tech
>If they did care, some of these things could have been added instead of 
>querying on object fields that most people will eventually wish they didn’t 
>use in the first place.

This made me smile a lot.I had exactly the same thought.  It brings back 
memories of subtables which I'm sure every 4D old-timer regrets ever using, if 
they ever did.  Someone could compile a list of 4D features with a recommended 
"steer clear of this to avoid regret later"  ;-)

To add my 0.02p on components:-

No.  Don't like them.  Don't use them in our coding.   I'd only ever use them 
for an essential 3rd Party "drop-in" black-box component that I have no 
intention of amending the source code for, so much akin to plug-ins.

Other than that, I can only echo what others have said about wanting the 4D 
language moved forward a bit.  I do recall that 4D did say at a Paris Summit 
that they had decided to re-commit to the 4D language.  Adding multi-threading 
support is possibly a sign of that decision, even though I really dislike their 
implementation of it.

Best regards

Keith White
Synergist Express Ltd, UK.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Dynamic Method Creation & Content Changing

2017-04-21 Thread truegold via 4D_Tech
Hi Nigel,

First I know the issue of using 4D List as a short cut for using a real lookup 
of records in a table, aka choice list, for example. I have a client who has an 
app (I have inherited this one as well) where there are hundreds of these and 
they are having the kinds of problems you mentioned.  I am slowly replacing 
them with table based choice list lookups.

But after reading your thoughts I realize that in this case I am not really 
doing anything dynamically EXCEPT when things need to be setup for a new study. 
And in this case without rewriting the application it must be handled the way I 
have described. So keep in mind that I have not been tasked to rewrite the App 
but only help them make this aspect of it easier.

SO the dynamic is really a one time thing. What I am really trying do is 
automate it and reduce the chances for error and not have to go through obscure 
notes to figure it out.

There are several NEW 4D lists that must be created each time they create a new 
study. Then these list need to referenced and part of the mechanism is by 
adding the names of these list to another meta list. That’s where the insert 
list items comes in.

Then there are two new methods created each time that use these NEW list. An 
the list names and number are the only thing that changes inside of this 
wrapper method that calls another method with these list names as parameters.

Outside of header and some variable declarations there is a single line of code 
which is the method and parameter list. Not much to validate here.

As to writing code inside another method that’s trickier. I might just open the 
methods and present the code lines for them to copy them in.

It’s not as bad as you think (or else I am a bit delusional! Sometimes it’s 
hard to tell. ) and on the surface it seems quite easy.

I’ll be explaining it to the client today and see what they think. If they say 
go for it then I’ll give it a try and see if I can get most of it automated.

I hope that explains it better. Always hard to explain when you’re trying not 
to be verbose.

Appreciate,
John...

> 4D lists can suck if they are being edited..I remember having trouble with a 
> system a while back where users complained that some drop downs did not have 
> something in that should have been there..testing showed that we had code 
> nicely adding to the 4D list that was being used in the drop down..lots of 
> head scratching..probably a blame fest..then we worked out what was going 
> to..the list we being written to by other clients overwriting the list. and 
> the user had a list different to what they expected.
> 
> In General I avoid using a 4D list for anything dynamic…a table with  
> something like…
> OWNER(User)<-create one ‘system’ owned list for each list name and where no 
> user specific version use the system version…(Duplicate records or combine 
> system owned with private owned)
> LIST_NAME
> LIST_ITEM_NAME
> NAME_ABBREV
> STUDY_REF 
> ..(and a record ID)
> Would be probably be a better way to handle a dynamic list and easier to then 
> relate something like study steps ..step items…step item options..etc
> 
> In my humble you should never need to have code edit itself for this kind of 
> purpose. The code should support and be supported by the data and switches in 
> the data should define the route through the code…that will always be more 
> robust and easier to write than code that writes code. 
> 
> Code that writes code is hard to validate:)..i know this ..lets say in your 
> code you have a line $_t_InsertStatement:=“IF(<>MyBadlyNamedVariable)” 1stly 
> you have to be sure that variable exists. and then if someone decides 
> somewhere to change the name of the variable it wont automatically change in 
> your hardcoded insert line and somewhere you will be getting calls about an 
> error..even worse is when 4D changes the name of the a function call or the 
> parameters.
> 
> Just my tuppence worth.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread John DeSoi via 4D_Tech
I'm fairly new to components also, and what you describe below is pretty much 
how I'm doing it. Anything reusable goes in one component library. But I want 
to use different subsets of this for different projects. I have "build methods" 
which specify which methods (modules) should be shared for the compiled 
component. So this allows different compiled components to be created with 
different sets of features from the same source structure. I have a parser 
almost done. I will eventually remove all unused code from the component before 
compilation rather than just hiding methods by making them unshared.

John DeSoi, Ph.D.



> On Apr 20, 2017, at 6:32 PM, David Adams via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I might give components one more try by putting everything into an
> OmniJumble component and having the host call it all of the time. Not
> really a sensible way to organize libraries, but it may be as good as I can
> get. My main goal, in this case, is to hide a lot of the plumbing on a
> large body of code. I'm not trying to hide the code per se (if I give out
> the component, I'd give out the code), but to make the calls easier to work
> with. Your idea about colored method names would help here too.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Methods, Components, Comments, and Tooltips

2017-04-21 Thread Chip Scheide via 4D_Tech
What does this project method look like?

Case of
:(form event=)
  case of
   :(Last object = )
 do stuff




On Fri, 21 Apr 2017 07:49:11 -0500, John DeSoi via 4D_Tech wrote:
> I recently embarked on an automated testing project and implemented 
> the advantages you mention by automatically generating *one* project 
> method per form that contains all of the object method and form 
> method code. The only other task was to create wrappers for Form 
> event and OBJECT Get pointer to allow them to be programmatically 
> manipulated.
> 
> So no rewriting of the form is necessary, no need to call a project 
> method from every object method, and no need to maintain an enormous 
> case statement for a form with lots of object methods. The "form 
> controller" idea others have mentioned might be nice for newer 
> projects, but would be a huge amount of work for legacy projects 
> where object names did not exist. My generated code has lots of 
> "Field1", "Field2", "Button1" names because object names never 
> mattered when the forms were created.
> 
> John DeSoi, Ph.D.
> 
> 
>> On Apr 20, 2017, at 4:34 PM, David Adams via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> Using a project method in place of a a form method/object scripts has a
>> couple of other advantages. If you pass in the event code, then you can:
>> 
>> * Create custom event codes ('redraw', 'close' or something more like a
>> message)
>> 
>> * Emulate form activity (useful for testing)
>> 
>> * Leverage your existing code with CALL FORM. Your CALL FORM call invokes
>> the form handler method and passes in whatever event or data is required.
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Methods, Components, Comments, and Tooltips

2017-04-21 Thread Chip Scheide via 4D_Tech
I have asked for - repeatedly - 
4D to give us an automated means to "fix" this.
http://forums.4d.fr/Post/EN/8282868/1/8282870#8282870
(15 votes from 2012)

Basically - a means to change unchanged object names (variable1, Field3 
etc) to AT LEAST the variable name,
but with an option to pre/post append a fixed string (Ex: "obj_"  --> 
obj_My_Variable) to be able to distinguish between veritable references 
and object references.
 
and from Bob Miller:
http://forums.4d.fr/Post/EN/13792407/1/13792408#13792408

On Fri, 21 Apr 2017 07:49:11 -0500, John DeSoi via 4D_Tech wrote:
> I recently embarked on an automated testing project and implemented 
> the advantages you mention by automatically generating *one* project 
> method per form that contains all of the object method and form 
> method code. The only other task was to create wrappers for Form 
> event and OBJECT Get pointer to allow them to be programmatically 
> manipulated.
> 
> So no rewriting of the form is necessary, no need to call a project 
> method from every object method, and no need to maintain an enormous 
> case statement for a form with lots of object methods. The "form 
> controller" idea others have mentioned might be nice for newer 
> projects, but would be a huge amount of work for legacy projects 
> where object names did not exist. My generated code has lots of 
> "Field1", "Field2", "Button1" names because object names never 
> mattered when the forms were created.
> 
> John DeSoi, Ph.D.
> 
> 
>> On Apr 20, 2017, at 4:34 PM, David Adams via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> Using a project method in place of a a form method/object scripts has a
>> couple of other advantages. If you pass in the event code, then you can:
>> 
>> * Create custom event codes ('redraw', 'close' or something more like a
>> message)
>> 
>> * Emulate form activity (useful for testing)
>> 
>> * Leverage your existing code with CALL FORM. Your CALL FORM call invokes
>> the form handler method and passes in whatever event or data is required.
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Methods, Components, Comments, and Tooltips

2017-04-21 Thread John DeSoi via 4D_Tech
I recently embarked on an automated testing project and implemented the 
advantages you mention by automatically generating *one* project method per 
form that contains all of the object method and form method code. The only 
other task was to create wrappers for Form event and OBJECT Get pointer to 
allow them to be programmatically manipulated.

So no rewriting of the form is necessary, no need to call a project method from 
every object method, and no need to maintain an enormous case statement for a 
form with lots of object methods. The "form controller" idea others have 
mentioned might be nice for newer projects, but would be a huge amount of work 
for legacy projects where object names did not exist. My generated code has 
lots of "Field1", "Field2", "Button1" names because object names never mattered 
when the forms were created.

John DeSoi, Ph.D.


> On Apr 20, 2017, at 4:34 PM, David Adams via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Using a project method in place of a a form method/object scripts has a
> couple of other advantages. If you pass in the event code, then you can:
> 
> * Create custom event codes ('redraw', 'close' or something more like a
> message)
> 
> * Emulate form activity (useful for testing)
> 
> * Leverage your existing code with CALL FORM. Your CALL FORM call invokes
> the form handler method and passes in whatever event or data is required.

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Converting Little Endian Byte Representation To a String

2017-04-21 Thread Arnaud de Montard via 4D_Tech

> Le 17 avr. 2017 à 23:36, Cannon Smith via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> I have a little problem I’m hoping someone can help me solve. First, a bit of 
> background. Our application deals with RFID tags for animals. These are 
> always 15 digit numbers like 124000123456789. Even though they are numbers, I 
> never have to deal with them as numbers. Instead, I always treat them as 
> strings. RFID readers are usually RS-232 devices that send the tag number 
> over as a string, so that works out well.[...]

Hi Cannon, 
just thinking about the opposite option… 
You store the number as a string because that number is "too big" for 4D 
numeric fields. Now, 15 digits string means 15*2 chars in an alpha/text field = 
30 bytes, and not a number as a result. While a uuid field is a number, 16 
bytes, represented by 32 chars. I'm wondering if a uuid field instead wouldn't 
be better.  

-- 
Arnaud de Montard 




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Dynamic Method Creation & Content Changing

2017-04-21 Thread Nigel Greenlee via 4D_Tech
John



4D lists can suck if they are being edited..I remember having trouble with a 
system a while back where users complained that some drop downs did not have 
something in that should have been there..testing showed that we had code 
nicely adding to the 4D list that was being used in the drop down..lots of head 
scratching..probably a blame fest..then we worked out what was going to..the 
list we being written to by other clients overwriting the list. and the user 
had a list different to what they expected.

In General I avoid using a 4D list for anything dynamic…a table with  something 
like…
OWNER(User)<-create one ‘system’ owned list for each list name and where no 
user specific version use the system version…(Duplicate records or combine 
system owned with private owned)
LIST_NAME
LIST_ITEM_NAME
NAME_ABBREV
STUDY_REF 
..(and a record ID)
Would be probably be a better way to handle a dynamic list and easier to then 
relate something like study steps ..step items…step item options..etc

In my humble you should never need to have code edit itself for this kind of 
purpose. The code should support and be supported by the data and switches in 
the data should define the route through the code…that will always be more 
robust and easier to write than code that writes code. 

Code that writes code is hard to validate:)..i know this ..lets say in your 
code you have a line $_t_InsertStatement:=“IF(<>MyBadlyNamedVariable)” 1stly 
you have to be sure that variable exists. and then if someone decides somewhere 
to change the name of the variable it wont automatically change in your 
hardcoded insert line and somewhere you will be getting calls about an 
error..even worse is when 4D changes the name of the a function call or the 
parameters.

Just my tuppence worth.


> On 21 Apr 2017, at 00:42, truegold via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
> Hi David,
> 
> First this is an App I took over and am maintaining. The client brought this 
> to my attention because after working in the app since the late 80’s it’s 
> still not clear and easy to remember all the steps (even with documentation) 
> it takes to get things to the point of usability.
> 
> As I look at it I see several 4D list that need to be created. I see list 
> items that need to be inserted into existing 4D list. I see several methods 
> that have to be created (using generic routines where all that changes are 
> the parameters names), and several methods that have to have code inserted 
> into case statements.
> 
> So most of seems to me can be automated. Probably need a UI of some sort to 
> add the name, abbreviation, and study number. (Then I can generate most 
> things on the fly and view ten in the UI before it’s committed.)
> 
> All of this is for setting things up so that another routine will be run that 
> reprocesses all this information crafting necessary records that are used 
> based upon all these new constructs. And then, finally, the study can begin 
> and data captured.
> 
> BTW, I’m intentionally trying not to explain everything as it’s a long and 
> winding road…
> 
> Brittle? I suppose. But if automated less chance for error I think. Less need 
> to reread and restudy somewhat unintuitive notes (yes I could rewrite them so 
> they are clearer).
> 
> Anyway, my main concern was with dynamic method creation and inserting lines 
> of code into existing methods. If it can be done then it’s something I might 
> pursue - if the client thinks it might be worth it.
> 
> Otherwise I’ll trudge through the notes and create the structure manually.
> 
> Kind of a proof in concept is what I’m after.
> 
> Thanks for your thoughts,
> John…
> 
> 
>> A method is just a block of text. The magic in the method comes from 4D's
>> interpreter. I modify methods via code and also do lots of code generation
>> for my standard housekeeping sort of code. You can get and set the text
>> however you like.
>> 
>> With that said, I don't see why you would do it in this case. It sounds
>> like you've got some user configurable data that you need to do lookups on
>> or otherwise manipulate. (Or are they a sort of decision-tree or driving a
>> logic cascade?) Right now you're keeping it in a 4D list and are proposing
>> to bake it into code. I think that the problem is that you're using lists
>> for data that should be in the data file. Before baking the data into code,
>> try and answer the question "how would I do this using the data file?" The
>> data file is a great place to keep user-specific config data and such. If
>> not there, then in a disk file. Putting the data into the data file makes
>> is easier to see, reuse, validate, etc.
>> 
>> Speaking of validation, it sounds like the setup is a bit brittle and easy
>> to mess up. Another solid argument for the data file. You need a UI for the
>> configuration entry which creates the configuration data. Then you can have
>> a *different* piece of code that interprets and validates the configuration

Re: Components: How do you reuse utility code?

2017-04-21 Thread David Adams via 4D_Tech
On Fri, Apr 21, 2017 at 2:45 PM, Tim Nevels via 4D_Tech <
4d_tech@lists.4d.com> wrote:


> Just before I clicked “Send” on my post I thought “this is probably gonna
> crawl under David’s skin, I can’t wait to read his reply”. You certainly
> did not disappoint. :) And that is a smiley face because I was smiling the
> entire time I was reading it.


 Oh fine, be that way. Yup, I feel into your trapglad we actually agree
more than not!
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Components: How do you reuse utility code?

2017-04-21 Thread David Adams via 4D_Tech
On Fri, Apr 21, 2017 at 2:39 PM, James Crate via 4D_Tech <
4d_tech@lists.4d.com> wrote:


> A few more less important things that are in almost every modern language
> that would make coding nicer for everyone, and could be added without
> affecting legacy code:
>


 +1 on your list. And while The Language Guy (TLG) is around, let's get a
few more things done:

--  More operators, like ++ and so on. Why not? That won't break old code.

-- Short-circuit evaluation of conjoined ifs. I don't think that will break
any old code, given how interpretation works now. If it does, a
compatibility setting or drop-dead conversion version seems fair.

And, since TLG has extra time after doing all of these,

METHOD GET PARSE TREE

Just give us a navigable parse tree from the specified method. I mean, the
4D interpreter is already building such a thing and so is the compiler. The
idea is that you get back a version of the code *that is already fully
parsed*. It might have to be XML, as you need nodes to have a type
(command, plug-in, method, constant, etc.) and contents (Open Window, etc.)
I say a tree because that's what would make sense. A branch for each line
and then an interpretation/parse tree for each line. This is handy to have *as
4D sees it*  because 4D follows its own rules. For example, I think it does
evaluations left-right rather than by order of precedence. The interpreter
does this sort of parsing every single day, so it's not like this is a new
feature. What's new is exposing the underlying structure to us for reuse.
With such a command, we would be free to write whatever code-analysis tools
we want.

A thousand flowers bloom.

P.S. Yes, I know about the token format for METHOD GET CODE. Not what I'm
talking about, but glad it exists. The token format doesn't simplify
writing a parser, but it does make writing an accurate parser easier.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**