|
![]() |
#1 |
Moderator
|
|
|
![]() |
#2 |
NavAx
|
Цитата:
![]()
__________________
Isn't it nice when things just work? |
|
![]() |
#3 |
Сам.AX
|
Извиняюсь за оффтоп, немного иная история.
Но как бы вы отреагировали, увидев такой код. PHP код:
![]()
__________________
"Считать метафору доказательством, поток праздных слов источником истины, а себя оракулом - это заблуждение, свойственное всем нам." Поль Валери |
|
![]() |
#4 |
Участник
|
ну да, для типизированных языков, конструкция сравнения с константами избыточна, но не смертельна, лишь бы логически верный результат был и ожидаемое поведение.
![]() Но к примеру на JavaScript, можно просто завести переменную, не инициализировать ее и фактически будет три значения true, false, null поэтому для упрощения можно использовать сравнение с какой либо константой, отметая два других значения, например, != true. X++: var flagTest; //.. flagTest=$("CheckBoxTest").selected; //... if(flagTest !=true) { } X++: bool? test = null; if (test) { } X++: bool? test = null; if (test == true) { }
__________________
Sergey Nefedov Последний раз редактировалось SRF; 23.05.2012 в 12:04. |
|
|
За это сообщение автора поблагодарили: fed (2). |
![]() |
#5 |
MCP
|
В PriceDisc.findPrice():
X++: return ((findAll && inventDimAllActivated.RecId && this.findPriceAgreement(_priceGroupId, inventDimAllActivated.inventDimId)) ||
(findItemDim && inventDimItemDimActivated.recId && this.findPriceAgreement(_priceGroupId, inventDimItemDimActivated.inventDimId)) ||
this.findPriceAgreement(_priceGroupId, InventDim::inventDimIdBlank()) ||
this.findItemPrice()); В return неудобно анализировать такой код. В классе sysDatabaseList метод new: X++: ...
while (1 == 1 && listOfNames)
{
}
... Последний раз редактировалось kornix; 23.05.2012 в 15:11. |
|
|
За это сообщение автора поблагодарили: macklakov (1). |
![]() |
#6 |
Участник
|
Общеизвестно, что для работы разработчиком Dynamics AX не обязательно знать X++ или уметь программировать.
Пример из LedgerJournalEngine\projQtyModified (AX 2012): X++: // This switch handles the normal(default) case and 2 other special cases switch(true) { case _ledgerJournalTrans_Project.Qty == 0: _ledgerJournalTrans.AmountCurCredit = 0; _ledgerJournalTrans.AmountCurDebit = 0; break; // If Credit/Debit Amounts are both 0, the Cost Price would be incorrectly set to 0 in the normal case // Handle this case separately case !_ledgerJournalTrans.AmountCurDebit && !_ledgerJournalTrans.AmountCurCredit && _ledgerJournalTrans_Project.CostPrice: this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project); break; default: // this.amount gets the debit amount or the negative credit amount offsetFactor = this.projOffsetFactor(_ledgerJournalTrans, _ledgerJournalTrans_Project); _ledgerJournalTrans_Project.CostPrice = Currency::price((offsetFactor * _ledgerJournalTrans.amount())/_ledgerJournalTrans_Project.Qty); // Cost Price should always be positive if (_ledgerJournalTrans_Project.CostPrice < 0) _ledgerJournalTrans_Project.CostPrice = - _ledgerJournalTrans_Project.CostPrice; // Cost Price have changed, recalc debit and credit amounts to avoid rounding diff this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project); break; } |
|
|
За это сообщение автора поблагодарили: macklakov (1), Zabr (12), db (0). |
![]() |
#7 |
Moderator
|
Цитата:
Сообщение от Napalm
![]() Общеизвестно, что для работы разработчиком Dynamics AX не обязательно знать X++ или уметь программировать.
Пример из LedgerJournalEngine\projQtyModified (AX 2012): X++: // This switch handles the normal(default) case and 2 other special cases switch(true) { case _ledgerJournalTrans_Project.Qty == 0: _ledgerJournalTrans.AmountCurCredit = 0; _ledgerJournalTrans.AmountCurDebit = 0; break; // If Credit/Debit Amounts are both 0, the Cost Price would be incorrectly set to 0 in the normal case // Handle this case separately case !_ledgerJournalTrans.AmountCurDebit && !_ledgerJournalTrans.AmountCurCredit && _ledgerJournalTrans_Project.CostPrice: this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project); break; default: // this.amount gets the debit amount or the negative credit amount offsetFactor = this.projOffsetFactor(_ledgerJournalTrans, _ledgerJournalTrans_Project); _ledgerJournalTrans_Project.CostPrice = Currency::price((offsetFactor * _ledgerJournalTrans.amount())/_ledgerJournalTrans_Project.Qty); // Cost Price should always be positive if (_ledgerJournalTrans_Project.CostPrice < 0) _ledgerJournalTrans_Project.CostPrice = - _ledgerJournalTrans_Project.CostPrice; // Cost Price have changed, recalc debit and credit amounts to avoid rounding diff this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project); break; } Для раздумья о нелегкой судьбе оператора switch() в различных языках программирования, рекомендую прочитать: Duff's device |
|
|
![]() |
||||
Тема | Ответов | |||
Бага в Query update(true) | 5 | |||
Не срабатывает skipDatabaseLog(true) | 14 | |||
visible(true) и курсор | 6 | |||
recordLevelSecurity(true) | 12 |
Опции темы | Поиск в этой теме |
Опции просмотра | |
|