hash for storing variables

hash for storing variables

Postby Otto » Tue Nov 28, 2023 7: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: hash for storing variables

Postby Enrico Maria Giordano » Tue Nov 28, 2023 8:28 am

It does not make sense to me. What do you want to get?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: hash for storing variables

Postby Otto » Tue Nov 28, 2023 8:40 am

Enrico, I use a patcher and preprocessor for my programming.

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.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: hash for storing variables

Postby Enrico Maria Giordano » Tue Nov 28, 2023 8:44 am

What is the point of using h["cTmp"] as the FOR EACH variable?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: hash for storing variables

Postby Otto » Tue Nov 28, 2023 8:47 am

Hello Enrico,
for e.g. my code looks like this.
All the moduls are this way independent.

Best regads,
Otto

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: hash for storing variables

Postby Enrico Maria Giordano » Tue Nov 28, 2023 8:54 am

I do not understand, sorry. Anyway, it still does not make sense.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: hash for storing variables

Postby Otto » Tue Nov 28, 2023 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: hash for storing variables

Postby Otto » Tue Nov 28, 2023 5:21 pm

Hello friends,

Here is an example of a test program.

All these blocks are reusable in all my programs.

Best regards,
Otto


Image

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests