Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 2 Jahren, 7 Monaten
Letzter Beitrag:
vor 2 Jahren, 7 Monaten
Beteiligte Autoren:
Alexandre Leclerc, Ola, Sascha77, Stewart Crisler, Marc De Swert, GuenterP

Question

Startbeitrag von GuenterP am 16.07.2015 05:54

Hi, just for my pure interest, a question:

Who has ever used the WLanguage keyword WITH .. END ???

Antworten:

honestly i did not even know that this construct is available in WX. I am using it when i am working with .NET - so i may will used it in WX as well.

Thx for the hint!

Sascha

von Sascha77 - am 16.07.2015 06:18
but can not find WITH in Wd18

von Marc De Swert - am 16.07.2015 07:21
Hi Marc,

This is a new feature of version 19. I just started to use it a few times.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 16.07.2015 12:56
Did not know we have this construct in WinDev. I use WITH all the time in Visual Foxpro. When you need to do many things, I have always assumed this was more efficient since you only have to evaluate the root element once. Now that I know it is there, I will be using it.

Stewart Crisler

von Stewart Crisler - am 16.07.2015 16:42
Hi all

Please correct me if I am wrong, but I understand that, for instance:

Product.ProdNo = 123
Product.ProdName = "Screw"

is equal to

With Product
.ProdNo = 123
.ProdName = "Screw"
END

so what is the big deal?

What are the benefits and drawbacks of the With - End structure?

I see one big con: when doing a global search for any Product file's items, I would not find them in the With - End structures.

What are the pros?

Best regards
Ola

von Ola - am 17.07.2015 06:55
HI Ola,

The Pros are that you have less typing and with your global search you would find the with structure where the file is used and I would not see that as a CON.

Cheers,
Sascha

von Sascha77 - am 17.07.2015 08:47
Hi Ola,

We do a lot of OOP. The gains are big in some use case.

pclMainModel.m_tabItems.m_sName = ""
pclMainModel.m_tabItems.m_sDescription = ""
pclMainModel.m_tabItems.m_sOption = ""

Other solution:
// Shorten in using a pointer to the item (and is thread safe, sort-safe, for the array)
pclItem is a CItem dynamic = pclMainModel.m_tabItems
pclItem.m_sName = ""
pclItem.m_sDescription = ""
pclItem.m_sOption = ""

Other solution:
// Shorten in using WITH
WITH pclMainModel.m_tabItems
.m_sName = ""
.m_sDescription = ""
.m_sOption = ""
END

Other solution:
// Shorten in using pointer and WITH (necessary in some cases to be thread safe, sort-safe, with the array)
pclItem is a CItem dynamic = pclMainModel.m_tabItems
WITH pclItem
.m_sName = ""
.m_sDescription = ""
.m_sOption = ""
END

Etc.

Some other use case are when you have a lot of members to work with at the same time. You save, again, a lot of coding. (This example has only 3 members. I use it when it is obviously a gain of time.)

Best regards,
Alexandre Leclerc


von Alexandre Leclerc - am 17.07.2015 12:19
Thanks Alexander & Sascha

Ola

von Ola - am 18.07.2015 16:16
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.