PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Question
Question
Iniciado por guest, 16,jul. 2015 07:54 - 8 respuestas
Publicado el 16,julio 2015 - 07:54
Poll: Who of you has ever used the WLanguage keyword WITH ?

Hi, just for my pure interest, a question:

Who has ever used the WLanguage keyword WITH .. END ???
Publicado el 16,julio 2015 - 08:18
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
Publicado el 16,julio 2015 - 09:21
but can not find WITH in Wd18
Publicado el 16,julio 2015 - 14:56
Hi Marc,

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

Best regards,
Alexandre Leclerc
Publicado el 16,julio 2015 - 18:42
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
Publicado el 17,julio 2015 - 08:55
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
Publicado el 17,julio 2015 - 10:47
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
Publicado el 17,julio 2015 - 14:19
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
Publicado el 18,julio 2015 - 18:16
Thanks Alexander & Sascha

Ola