AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

^pos(place)
 
 

The logic for the ^pos(place) function is incorrect when handling 1st and 2nd.

int value = (int)Convert2Integer(arg2);
 if ((
value) == 1sprintf(buffer,"%dst",value); 
 if ((
value) == 2sprintf(buffer,"%dnd",value);
 if ((
value) == 3sprintf(buffer,"%drd",value);
 else 
sprintf(buffer,"%dth",value); 

The numbers ending 1 and 2 are independent tests and hence get trampled over by the else when it is not ending in 3!

 

 

 
  [ # 1 ]

It SOUNDS like you are suggesting there is a flaw in my code.
Oh well, consider it fixed for next release. thanks.

 

 
  [ # 2 ]

Just trying to present unassailable evidence, got to keep my almost daily posting sequence going somehow.
Thanks

 

 
  [ # 3 ]

Just wondering about that code since I’ve dealt with this in my own programming: Shouldn’t it also do “21st”, “22nd” and “23rd”? As in;

if ((value) % 100 == 11 || (value) % 100 == 12 || (value) % 100 == 13sprintf(buffer,"%dth",value); 
else if ((
value) % 10 == 1sprintf(buffer,"%dst",value); 
else if ((
value) % 10 == 2sprintf(buffer,"%dnd",value);
else if ((
value) % 10 == 3sprintf(buffer,"%drd",value);
else 
sprintf(buffer,"%dth",value); 
 

 
  [ # 4 ]

You don’t want 11st as a place number?  OK. changed to:
int val = atoi(arg2);
if (val == 11 || val == 12 || val == 13) sprintf(buffer,”%dth”,val);
else if (c == ‘1’) sprintf(buffer,”%sst”,arg2);
else if (c == ‘2’) sprintf(buffer,”%snd”,arg2);
else if (c == ‘3’) sprintf(buffer,”%srd”,arg2);
else if (IsDigit(*arg2)) sprintf(buffer,”%sth”,arg2);
else strcpy(buffer,arg2); // first, second, third etc

 

 
  [ # 5 ]

This is still not quite right in POSCode in version 6.2c.

There are two places (no pun intended) where there is place handling code. The above code is only for ^pos(conjugate 11 #PLACE_NUMBER) and doesn’t handle 111th correctly.

But there is also ^pos(place 11) that needs to be modified.

 

 
  [ # 6 ]
u: (place)
 $
$numbers "1 2 3 4 11 12 13 14 21 22 23 24 101 102 103 104 111 112 113 114"
 
@= ^burst($$numbers)
 ^
loop()
 
{
  
$$n = ^first(@0subject)
  $
$n is conjugated as ^pos(conjugate $$n #PLACE_NUMBER) and placed as ^pos(place $$n) \n
 

111-113 are conjugated incorrectly.
11-13 and 111-113 are placed incorrectly.

 

 

 
  [ # 7 ]

That’s why I suggested

if (value 100 == 11{} 

This does as much as cut off everything above 100. ‘%’ is a weird operator, but handy.

 

 
  login or register to react