|
|
|
|||||
|
Hello everybody!
I'm currently stuck with Fatal PHP error that I cannot explain. Perhaps you guys can help me. So.. in my .ice file there is a record in interface: Code:
int apiTradesCalcProfit(string group, TradeRecord TrIn, out TradeRecord TrOut) throws ServerError; PHP Code:
Code:
Fatal error: Ice_ObjectPrx::apitradescalcprofit() : expected int value but received null in ice_test.php on line 53 Code:
res = initial.apiTradesCalcProfit(group, t) |
|
||||||
|
Hi,
As described in the manual, "out" parameters must be passed by reference in PHP. Using your example, the final parameter should be changed as follows: Code:
$initial->apiTradesCalcProfit($group, $t, &$res); Cheers, Mark |
|
|||||
|
Surely I tried to put ampersand in front of $res. With no success: PHP throws the same Fatal Error..
|
|
|||||
|
Quote:
Here is the snippet of PHP code:PHP Code:
Code:
module MTServer {
struct ConSymbol {
...a lot of stuff here..
};
struct TradeRecord {
...a lot of stuff here...
};
interface Morda {
//return: TRUE or exception
int apiSymbolsGet(string symbol, out ConSymbol SymbolStruct) throws ServerError;
//return: RET_OK or exception
int apiHistoryPrices(string symbol, out double bid, out double ask, out int time) throws ServerError;
int apiTradesCalcProfit(string group, TradeRecord TrIn, out TradeRecord TrOut) throws ServerError;
};
};
Code:
import Ice
Ice.loadSlice('My.ice')
import MTServer
base = Ice.initialize().stringToProxy(MT:tcp -h ice.server.tld -p 10000')
mtsrv = MTServer.MordaPrx.checkedCast(base)
symbol = "EURUSD"
sg = mtsrv.apiSymbolsGet(symbol)
prices = mtsrv.apiHistoryPrices(symbol)
t = MTServer.TradeRecord()
t.symbol = symbol
t.volume=100
t.OpenPrice = prices[1]
t.ClosePrice = prices[1] + sg[1].point
res = mtsrv.apiTradesCalcProfit("Forex_USD", t)
print res #prints what expected
|
|
||||||
|
Hi,
I suspect the problem is caused by an uninitialized integer data member in your structure; PHP initializes the member to a null value by default, but the Ice extension expects an integer value. The Ice extension only accepts a null value for strings, objects and proxies; all other types must be initialized with a suitable default value. We'll look at improving this situation in a future release. Take care, Mark |
|
|||||
|
Quote:
![]() |
|
||||||
|
Hi,
I'm glad to hear that you resolved the problem. Note that the final release of Ice 3.3.0 will add support for constructors in structures, exceptions and classes that initialize data members to legal default values. Take care, Mark |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strange SEGV ... | joel vennin | Help Center | 3 | 08-02-2006 05:10 AM |
| Ice 2.1.2 and PHP SSL error ??? | surfer | Help Center | 4 | 01-09-2006 06:29 AM |
| Strange compilation error with VC6 / Ice 1.4.0 | annekat | Help Center | 3 | 07-05-2004 02:15 PM |
| Ice php error report | fengxb | Help Center | 2 | 05-11-2004 07:06 AM |
| Ice Php 1.0.2 link error | fengxb | Help Center | 12 | 03-09-2004 01:08 AM |