Page 1 of 2

Blocking single and double quotes in GET

Posted: Tue May 17, 2016 11:13 pm
by Andy Edward
Hi Roger,

Background:
- We are using PostgresSQL with xBase++ 2.00.685 and Express++ 263
- DbCreateIndex() on fields containing single quote or double quotes fails in ISAM mode.
- It fails because it is using SQL's UPDATE command to populate the index column. Here is the error output from pg_log

Code: Select all

2016-05-18 14:10:31 MYT ERROR:  syntax error at or near "EQUITY" at character 56
2016-05-18 14:10:31 MYT STATEMENT:  UPDATE ac SET __order_acnme_acnme='TOTAL SHAREHOLDERS' EQUITY              100000                    1@0000000001' WHERE __RECORD=1;
Take note the single quote after "SHAREHOLDERS".

- We have contacted Alaska and they verified that this is a bug and opened a PDR here http://www.alaska-software.com/scripts/ ... PDRID=6724

While waiting for this issue to be resolved (if it's even being looked at), is there any way to block the DCGETs from accepting single quote and double quotes?

If I may give a suggestion, an option for DCGET like

Code: Select all

DCGET ... NOQUOTE
to indicate the GET to not accept single and double quotes, that would be ideal.

Note: If anyone is thinking about moving forward with Postgres and Xbase, kindly click the PDR link to boost the priority

Regards,

Andy

Re: Blocking single and double quotes in GET

Posted: Tue May 17, 2016 11:48 pm
by skiman
Hi,

Maybe just change your indexkey? If you use a user defined function in your index, you can strip/replace these characters. I suppose this will be the fastest way to solve this.

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 12:30 am
by Andy Edward
Hi Chris,

Thanks for your suggestion.

I've also tested using User Defined Index, it does strip all the single quote and the INDEX ON command ran just fine.
But another problem appears when doing a SEEK. It will not find the record that I want. Because the content I'm searching still has a single quote but the index have no single quote.

So using a user defined index will only solve the INDEX ON part. But when it comes to SEEK time, it will not find the record

Regards,

Andy

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 12:57 am
by skiman
Hi,

I always use the same function before my seek.
customer->(dbseek(strip( cSeek)))

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 1:39 am
by Andy Edward
Hi Chris,

Just like avoiding any code rewrites, which entails hundreds of hours of testing, we would not prefer to change the operational code.

We appreciate your solution, but as this is a deployed software in dozens of companies, we would prefer a less "invasive" solution, rather than going back and do code rewrites.

The current code is tested and working, so to circle back to the original question, if there is a way to block the GET from accepting single and double quotes, it would be ideal for our case.

Regards,

Andy

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 4:09 am
by Tom
Hi, Andy.

Build your own "NOQUOTE"-option. This works for single quotes:

Code: Select all

#xtranslate  NOQUOTE => ;
             KEYBLOCK {|x,y,o|CheckQuotes(x,y,o)}

#include "dcdialog.ch"
#include "appevent.ch"
#include "inkey.ch"

#pragma library ("dclipx.lib")

FUNCTION Main()
LOCAL GetList := {}, c := Space(30)

@ 1,1 DCSAY 'Test:' GET c SAYSIZE 10 NOQUOTE

DCREAD GUI FIT ADDBUTTONS

RETURN NIL

FUNCTION CheckQuotes(x,y,o)
IF Chr(x) == "'"
  PostAppEvent(xbeP_Keyboard,xbeK_BS,y,o)
ENDIF
RETURN NIL

PROC AppSys() ; RETURN
Edit: It works for typed single quotes. It does not work for pasted textes. You may change "CheckQuotes" and work with EditBuffer(), SetData() a.s.o. there.

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 11:26 am
by Cliff Wiernik
You could also add a custom keyhandler that would strip the quote for get fields.

Re: Blocking single and double quotes in GET

Posted: Wed May 18, 2016 12:35 pm
by rdonnay
is there any way to block the DCGETs from accepting single quote and double quotes?
Try this:

Code: Select all

@ .. DCGET .. KEYBLOCK {|a,b,o|IIF(a==Asc('"') .OR. a == Asc("'"),o:undo(),nil)}

Re: Blocking single and double quotes in GET

Posted: Thu May 19, 2016 12:06 am
by Tom
Undo() will erase the get contens completely. Try my suggestion; it works fine. Just add the characters you want to delete to the function.

Re: Blocking single and double quotes in GET

Posted: Thu May 19, 2016 8:34 am
by rdonnay
Undo() will erase the get contens completely. Try my suggestion; it works fine. Just add the characters you want to delete to the function.
Oops, I forgot about that, I was thinking o:get:delleft(), but that doesn't work right either. Your solution is best.