FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour hash for storing variables
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
hash for storing variables
Posted: Tue Nov 28, 2023 07:55 AM

Hello friends,

static h := {=>}

h['mycParts'] := {"date=1900-11-21", "time=16:00"}

// Correct loop syntax for iterating over the array in the hash

FOR EACH cTmp IN h['mycParts']

? cTmp

NEXT

But when I try to use

h["cTmp"] := ""

FOR EACH h["cTmp"]IN h['mycParts']

 ? h["cTmp"]

NEXT

I get a syntax error.

Is there a workaround?

Best regards,

Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 08:28 AM

It does not make sense to me. What do you want to get?

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 08:40 AM
Enrico, I use a patcher and preprocessor for my programming.

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=42693&p=260562&hilit=hash&sid=fef71b12cde0ab87a1d9048f22a2ff63#p260562

Best regards,
Otto



ADVANTAGES OF THE PATCHER AND PREPROCESSOR SYSTEM
The Patcher and Preprocessor system allows for the integration of components with simple instructions like
$-> DATEPICKER: id = dateInput.
This offers several benefits:
Clarity and Compactness:
The code remains clear and easy to read. Reusability: The same component can be reused in different parts of a project, simplifying maintenance. Centralized Updates: Changes to the DATEPICKER component need only be made in one place.
Separation of Structure and Logic:
The structure (HTML), style (CSS), and logic (JavaScript) of components can be edited independently. Consistency: Ensures consistent use of the date input component throughout the project.
Similarities with Object-Oriented Programming
The approach shares similarities with object-oriented programming (OOP), especially regarding modularity and encapsulation. However, it lacks classical OOP elements like inheritance and polymorphism. The use of multiple levels of patchers and preprocessors for composing components resembles the OOP principle of composition. This enhances reusability and maintainability and allows for a well-structured development of complex applications. However, it is not true OOP as the focus is more on reusing code snippets rather than creating and managing objects in the OOP sense.
Conclusion
In summary, this approach offers an efficient, modular, and component-based approach to web development. It shares many advantages of object-oriented programming, although it does not encompass all aspects of OOP. Centralizing style definitions and avoiding redundancies are important to minimize conflicts and maintenance issues.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 08:44 AM

What is the point of using h["cTmp"] as the FOR EACH variable?

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 08:47 AM
Hello Enrico,
for e.g. my code looks like this.
All the moduls are this way independent.

Best regads,
Otto



Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 08:54 AM

I do not understand, sorry. Anyway, it still does not make sense.

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 09:08 AM

Enrico, the advantage is that you have reusable blocks here and don't have to worry about passing the variables.

It's simply the productivity that is the advantage.

It's a method to make the source code more readable and secure.

Best regards,

Otto

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: hash for storing variables
Posted: Tue Nov 28, 2023 05:21 PM
Hello friends,

Here is an example of a test program.

All these blocks are reusable in all my programs.

Best regards,
Otto






Continue the discussion