RE: Accessibility: Fingerspelling program
Version 0.3 now implements a substitution list - so if you see 0 you can say "zero".
The need to run Hello World has been fixed.
Code:
READY();//FORWARD
LOCAL VERNUM:=0.3;
LOCAL CRID:="FINGERSPELLER © 2016 StephenG1CMZ"+CHAR(10);
//SHOWS CURRENT LANGUAGE. USERS USE FingersLang() FUNCTION
EXPORT FingersReady:=0;
EXPORT FingersLang;
LOCAL TRANSLATED:="";
LOCAL WORLD:="Hello World 2016";
//CUSTOMISE
LOCAL SECS:=1; //0=KEY WAIT - A SIMPLE WAIT
LOCAL CHEAT_MODE:=1; //0 , 1
LOCAL SHOW_REPLACED_TEXT:=1;//0, 1-ALSO REQUIRES CHEAT MODE
LOCAL ICEFS:="ICE_URGENT_MESSAGES";
LOCAL MYHELP:="FINGERSPELLER.HLP";
LOCAL SLFS:="FINGERSPELLERSL"; //SUBSTITUTION LIST
LOCAL DIAGNOSTIC:=0;
LOCAL Y0:=20;//HEADER HEIGHT 20, OR 0 TO USE TOP LINE
LOCAL DEFAULT_INSTALL:={"A_TEST","HUGE"};
//FULL VALUES:
//LOCAL FWIN:={0,Y0,320,200,0,220,320,220};//200-220 FOR CHEAT LINE
LOCAL FWIN:={320/2,Y0,320,200,0,200,320,220};
//USER VALUES MAY BE SMALLER TO SHARE SCREEN
//INPUT DATA RESOLUTION. USER ACCESS BY CharImgSize FUNCTION
LOCAL CHARIMGSIZE:={22,28};//SUITS TEST DATA. SIGNS PROBABLY LARGER
//ALTERNATIVELY READFILE FOR CUSTOMISED TEXT
LOCAL ICE_URGENT_MESSAGE_LST:={
"SOS",
"EVACUATE",
"EMERGENCY"};
// END CUSTOM
LOCAL FINGERLANGS:={};
LOCAL SZX:=320;
LOCAL SZY:=220-Y0;
LOCAL II,JJ,OKC;
LOCAL ROWS:=5;
LOCAL COLS:=6;
//LOCAL MYPX;
LOCAL FS:={};
LOCAL FSTMP:="AY_Temp";
LOCAL CHARSET:="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
LOCAL STRNG:="";
LOCAL FILESPEC:="";
LOCAL CHS,LANGN;
LOCAL LANG:="A_TEST";
LOCAL SUBSTL:={};
//HP COMMON
LOCAL IMP_LIMIT_PRINT:=2000;
LOCAL ZTypeNUMERIC:=0;
LOCAL ZTypeSTRING:=2;
LOCAL ZTypeLIST:=6;
//END HP COMMON
EXISTS(FS)
BEGIN //NOT IMPLEMENTED
RETURN 1;
END;
JUNKA(FS)
BEGIN
IF SIZE(FS) THEN //PRECAUTION
DelAFiles(FS);//Garbage Gone
END;
END;
SCR_PUT()
BEGIN
//MSGBOX("PUT:"+FSTMP);
AFiles(FSTMP+"G0"):=G0;//SAVE
AFiles(FSTMP+"G7"):=G7;
END;
SCR_GET()
BEGIN
//MSGBOX("GET:"+FSTMP);
//DEBUG;
G0:=AFiles(FSTMP+"G0");
G7:=AFiles(FSTMP+"G7");
JUNKA(FSTMP+"G0");
JUNKA(FSTMP+"G7");
END;
SHOWAZ (LANG)
BEGIN
LOCAL XX:=IP(SZX/COLS);
LOCAL YY:=IP(SZY/ROWS);
//LOCAL LIN;
LOCAL CN,XXX,YYY;
RECT_P(0,20,320,240);
FOR II FROM 0 TO ROWS-1 DO
FOR JJ FROM 0 TO COLS-1 DO
CN:=COLS*II+JJ+1;
IF CN≤26 THEN
FS(CN):=LANG+"_"+CHAR(ASC("A")+CN-1);//MUST MATCH BUILD
XXX:={JJ*XX,(JJ+1)*XX};
YYY:={II*YY+Y0,(II+1)*YY+Y0};
G7:=AFiles(FS(CN));
//BLIT_P(G0,XXX(1),YYY(1),XXX(2),YYY(2),G7,MIDX-2,MIDY-0,MIDX+20,MIDY+28);
BLIT_P(G0,XXX(1),YYY(1),XXX(2),YYY(2),G7,0,20,GROBW_P(G7),GROBH_P(G7));
RECT_P(XXX(1),YYY(1),XXX(2),YYY(2),0,{#FFFFFFh,0});
END;
END;
END;
DRAWMENU(LANG);
TEXTOUT_P(LANG+"- IMAGINE FINGERSPELL DATA HERE",0,0);
END;
DISPLAY_ONE (ST)
BEGIN
LOCAL LANG:=FingersLang;
//DONT INSIST ON ST==1CH HERE:EG ALLOW "GOOD" OR "E_ACUTE" FILENAMES
//MSGBOX(LANG);
G7:=AFiles(LANG+"_"+ST);//SIZE DEFINED BY FILE
IF DIAGNOSTIC THEN
PRINT();//IT HAS BEEN REPORTED THAT BLIT FAILS IN 10077 IN V0.1. WONDER WHAT SIZE IT IS?
PRINT("G7:"+GROBW_P(G7)+","+GROBH_P(G7));
END;
BLIT_P(G0,FWIN(1),FWIN(2),FWIN(3),FWIN(4),G7,0,20,GROBW_P(G7),GROBH_P(G7));
WAIT(SECS);
END;
LOAD_SL()
//LOAD SUBSTITUTION LIST FOR THAT LANG
BEGIN
SUBSTL:=EXPR(Notes(SLFS));
END;
ZSUBST(CH)
//! SHOULD WE TEST ASCII NUMBERS OR CHARS
BEGIN
LOCAL II;
LOCAL ITEM,ITEMIN,ITEMCODE;
LOCAL SUBTEXT:="";
FOR II FROM 1 TO SIZE(SUBSTL) DO
ITEM:=SUBSTL(II);
ITEMIN:=ITEM(1);
//IF ITEM A CH MAKE IT A CODE:WILL FAIL IF ITEM IS STRIG
IF TYPE(ITEMIN)==ZTypeSTRING THEN
ITEMCODE:=ASC(ITEMIN);
ELSE
ITEMCODE:=ITEMIN;
END;
//DEBUG;
CASE
IF TYPE(ITEMCODE)==ZTypeNUMERIC THEN //ASCII NUM
IF CH==CHAR(ITEMCODE) THEN
SUBTEXT:=ITEM(2);
END;
END;
IF TYPE(ITEMCODE)==ZTypeLIST THEN //UNICODE
IF CHAR(ITEMCODE)==CH THEN
//MSGBOX(ITEMCODE);
SUBTEXT:=ITEM(2);
END;
END;
DEFAULT
END;
END;
IF CH=="©" THEN
SUBTEXT:="COPYRIGHT";
END;
RETURN SUBTEXT;
END;
DO_FSPELL(ST,TOPCALL)
//AVOID SCREENSAVING HERE
//IDEALLY: EARLY COMPLETION TBD
BEGIN
LOCAL CH;
LOCAL II;
LOCAL SUBTEXT:="";
//ESCAPE IF GETKEY4 AND SECS≠0?TBD
FOR II FROM 1 TO DIM(ST) DO
CH:=UPPER(MID(ST,II,1));
IF TOPCALL THEN
//DEMO
SUBTEXT:=ZSUBST(CH);
IF SUBTEXT=="" THEN
ELSE
DO_FSPELL(SUBTEXT,SHOW_REPLACED_TEXT);
END;
END;
IF INSTRING(CHARSET,CH) THEN
IF TOPCALL THEN
RECT_P(FWIN(1),FWIN(2),FWIN(3),FWIN(4));
RECT_P(FWIN(5),FWIN(6),FWIN(7),FWIN(8));
IF CHEAT_MODE THEN //SHOW STRING PROGRESS IN USER STRING
//IMPROVES READABILITY BUT WILL WANT TO CUSTOMISE OUT IN TESTS
TEXTOUT_P(MID(ST,1,II),FWIN(5)+2,FWIN(6));//!!LONG TEXT WILL EXCEED WINDOW!!
DRAWMENU(II,DIM(ST));
ELSE
DRAWMENU("");
//(OTHERWISE USER MENU IS SEEN BUT NOT RESPONDED TO )
END;
END;
DISPLAY_ONE(CH);
ELSE
//IGNORE UNKNOWN CHARS
END;
END;
END;
Fingerspell_ST(STRNG)
//FINGERSPELL THE STRING-INTERNAL USE
BEGIN
LOCAL ST:=STRNG;
IF DIM(ST) THEN
//DO DISPLAY
READY();//DO BEFORE PUT (OR OPTIMISE PUTGET PUTGET)
SCR_PUT();
DO_FSPELL(ST,1);
SCR_GET();
END;
END;
FINGERSPELL_IN ()
BEGIN
LOCAL TTL:=CRID;
LOCAL LBL:={"String","File"};
LOCAL HLP:={"Enter String to Fingerspell (Quotes Not needed)","Enter File to Fingerspell EG: Notes(string) "};
LOCAL ST:={};
OKC:=INPUT({{STRNG,[ZTypeSTRING]},{FILESPEC,[2]}},TTL,LBL,HLP,{"",""},{STRNG,FILESPEC});
IF OKC THEN
IF DIM(FILESPEC) THEN
STRNG:=STRNG+EXPR(FILESPEC);
END;
Fingerspell_ST(STRNG);
END;
RETURN STRNG;
END;
FINGERSPELL_TAP (LANG)
BEGIN
RECT_P();
SHOWAZ(LANG);
TEXTOUT_P("BUTTONS NOT IMPLEMENTED",109,180);
TEXTOUT_P("KEY ESC TO CONTINUE",109,200);
WAIT;
RETURN "TBD";//TBD
END;
HELP()
BEGIN
LOCAL ST:=Notes(MYHELP);
OKC:=CHOOSE(CHS,"",{"As Text","Fingerspell"});
IF OKC THEN
PRINT();
PRINT(MID(ST,1,IMP_LIMIT_PRINT));
IF CHS==2 THEN
Fingerspell_ST(Notes(MYHELP));
END;
END;
END;
ABOUT()
BEGIN
LOCAL KK;
RECT_P();
TEXTOUT_P(CRID,0,20);
TEXTOUT_P(VERNUM,0,40);
TEXTOUT_P("Esc To Exit",0,80);
TEXTOUT_P("Enter To Fingerspell",0,100);
KK:=WAIT;
//HAVE TO WAIT CUZ BAD SUBST LIST CAN KILL SPELLER
IF KK≠4 THEN
Fingerspell_ST(CRID);
END;
WAIT;
END;
// USER INTERFACE API
// AY=ACCESSIBILITY
// ----------------
EXPORT ABOUT_HELP ()
BEGIN
OKC:=CHOOSE(CHS,"",{"ABOUT","HELP "+MYHELP});
IF OKC THEN
CASE
IF CHS==1 THEN ABOUT() END;
IF CHS==2 THEN HELP() END;
DEFAULT
END;
END;
END;
EXPORT Fingers_s(SECONDS)
//WAIT SECONDS EACH FINGERSPELLED CHAR
BEGIN
SECS:=SECONDS;
END;
EXPORT AY_Windows(WINLIST)
//SET WINDOW DISPLAY RECTANGLES
//1-4: WINDOW FOR FINGERSPELL GRAPHIC
//5-8: WINDOW FOR TEXTLINE
//OVERLAP: TEXTLINE OBSCURED
//INTENDED FOR USE BY USER PROGRAMS FOR SCREEN SHARING
BEGIN
IF SIZE(WINLIST)==8 THEN
FWIN:=WINLIST;
END;
RETURN FWIN;
END;
EXPORT FingersLanguage(LangSTR)
//SELECT FINGERSPELL LANGUAGE STRING
//"?" OR WRONG STRING RETURNS CURRENT LANG
//IDEALLY TEST THAT FILES ARE INSTALLED:NOT IMPLEMENTED HP
//SELECT "" TO DISABLE FINGERSPELL TBD
BEGIN
LOCAL ST:=LangSTR;
LOCAL PP:=POS(FINGERLANGS,ST);
IF PP THEN //LANGUAGE KNOWN
FingersLang:=FINGERLANGS(PP);
END;
LOAD_SL();
RETURN FingersLang;
//RETURN LANGUAGE:UNCHANGED IF UNKNOWN
//RETURN TEST IF NOT INSTALLED:TBD
END;
EXPORT ICE_URGENT_MESSAGES()
// SELECT 1 OF UP TO 2047 MESSAGES
BEGIN
//LOCAL INSTRS:={"To edit list:","ICE_URGENT_MESSAGE:={strings}"};//ONLY WHEN EXPORT
//MSGBOX()
ICE_URGENT_MESSAGE_LST:=EXPR(Notes(ICEFS));
OKC:=CHOOSE(CHS,"Select Message to Fingerspell",ICE_URGENT_MESSAGE_LST);
IF OKC THEN
IF CHS>0 THEN
PRINT();
PRINT(ICE_URGENT_MESSAGE_LST(CHS));
Fingerspell_ST(ICE_URGENT_MESSAGE_LST(CHS));
END;
END;
END;
EXPORT TranslateDeFingers()
BEGIN
LOCAL LANG:=FingersLang;
TRANSLATED:=FINGERSPELL_TAP(LANG);
RETURN TRANSLATED;
END;
EXPORT TranslateToFingers()
BEGIN
TRANSLATED:=FINGERSPELL_IN();
RETURN TRANSLATED;
END;
EXPORT TranslateFingers()
BEGIN
LOCAL STR;
OKC:=CHOOSE(CHS,"","Translate De Fingers","Translate To Fingers");
IF OKC THEN
IF CHS==1 THEN
STR:=TranslateDeFingers();
ELSE
STR:=TranslateToFingers();
END;
END;
END;
EXPORT Fingerspell(STRNG)
//FINGERSPELL STRING-EXTERNAL CALL
BEGIN
Fingerspell_ST(STRNG);
END;
EXPORT CharImgSize(XY_LIST)
//SIZE OF YOUR IMAGE DATA ie LARGEST CHARACTER IN LANGUAGE
//A SINGLE VALUE IS USED BUT IT COULD VARY...
//IF SOME IMAGES ARE LARGER THE OTHERS WILL BE SMALL:
//VARYING THE VALUES WOULD HELP
BEGIN
IF SIZE(XY_LIST)==2 THEN
CHARIMGSIZE:=XY_LIST
END;//OTHERWISE A QUERY
RETURN CHARIMGSIZE;
END;
//BUILD DEMO GRAPHICS
DO_INSTAL(ALANG)
BEGIN
IF POS(FINGERLANGS,"A_TEST") OR POS(FINGERLANGS,"HUGE") THEN
//PREPARE FILESPECS
FOR II FROM 1 TO 26 DO
FS(II):=LANG+"_"+CHAR(ASC("A")+II-1);
END;
//DEL OLDFILES?
OKC:=1;
//DEL OLDFILES
IF LANG=="A_TEST" THEN
FOR II FROM 1 TO 26 DO
DelAFiles(FS(II));
END;
DelAFiles(LANG);
END;
//BUILD NEW FILES
DIMGROB_P(G7,CHARIMGSIZE(1)+2,CHARIMGSIZE(2)+20);//OFFSETS AID READABILITY=AVOIDS TEXT AT EDGE
FOR II FROM 1 TO 26 DO
RECT_P(G7);
//TEXTOUT_P(CHAR(ASC("A")+II-1),G7,SZX/2,SZY/2,7);
TEXTOUT_P(CHAR(ASC("A")+II-1),G7,2,20,7);
//BLIT_P(G0,G7); //MAYBE SLOW ENOUGH TO SEE PROGRESS
AFiles(FS(II)):=G7; //CAN BE SLOW IF SAVING FULLSCREEN
//WAIT(0.1);
END;//FOR
AFiles(LANG):=CHARSET;//DOCUMENT THE INSTALLATION
END; //IF
END;
EXPORT INSTALL(MYLANGS)
BEGIN
LOCAL II;
CASE
IF TYPE(MYLANGS)==ZTypeNUMERIC THEN //NUM
IF MYLANGS==0 THEN //DEFAULT I
INSTALL(DEFAULT_INSTALL);//
END;
END;
IF TYPE(MYLANGS)==ZTypeSTRING THEN //ST
IF DIM(MYLANGS) THEN
IF MYLANGS=="?" THEN
ELSE
INSTALL({MYLANGS});
END;
END;
END;
IF TYPE(MYLANGS)==ZTypeLIST THEN //LST
SCR_PUT();
RECT_P();
TEXTOUT_P(CRID,0,0);
FOR II FROM 1 TO SIZE(MYLANGS) DO
IF POS(FINGERLANGS,MYLANGS(II)) THEN
//LANG ALREADY LISTED INSTALLED
ELSE
FINGERLANGS:=CONCAT(FINGERLANGS,MYLANGS(II));
END;
TEXTOUT_P("Install "+MYLANGS(II),0,20*POS(FINGERLANGS,MYLANGS(II)));
DO_INSTAL(MYLANGS(II));
//TEXTOUT_P("Installed: "+MYLANGS(II),0,20*POS(FINGERLANGS,MYLANGS(II)));
TEXTOUT_P("Installed: ",0,20*POS(FINGERLANGS,MYLANGS(II)));
//IF INSTALSLOW SHOWAZ("HUGE"); ETC
END;//FOR
//WAIT(1);//ALLOW LAST INSTAL TO BE SEEN
SCR_GET();
END;//IF
DEFAULT
END;
// RETURN LIST OF INSTALLED LANGS
// NB IT DOES NOT YET VERIFY FILES EXIST
RETURN FINGERLANGS;
END;
EXPORT RESET()
//RESETS TO USEFUL DEFAULTS
BEGIN
LOCAL STR,TEMPLIST;
INSTALL(DEFAULT_INSTALL);
OKC:=FingersLanguage("A_TEST");//THE LANG MUST HAVE BEEN INSTALLED
Fingers_s(SECS);
TEMPLIST:=AY_Windows({320/2,Y0,320,200,0,200,320,220});
//AY_SetWin({320/2,Y0,320,100,0,20,20,22});
FingersReady:=1;
END;
READY()
BEGIN
IF FingersReady==0 THEN
RESET();
END;
END;
//EXAMPLE DEMO
//...
EXAMPLE_DEMO()
BEGIN
LOCAL STR,TEMPLIST;
//AN EXAMPLE:HELLO WORLD
//NOW DEMONSTRATE ACCESSIBLE USE
//ENSURE LANGUAGE INSTALLED:ONCE PER APP (CAN BE SLOW)
// = NOT EVERY RUN
//DUPLICATES NOT ADDED AGAIN. YOU CAN ADD YOUR OWN LANG
//EXCEPT FOR HUGE AND A_TEST USER SUPPLIES GRAPHICS
INSTALL(DEFAULT_INSTALL);
//INSTALL("MY_OWN_LANG");
//OPTIONAL:BEST SET BY USER
OKC:=FingersLanguage("A_TEST");//THE LANG MUST HAVE BEEN INSTALLED
Fingers_s(SECS);
//SHOW THE GRAPHICS ALPHABET FOR INFO
STR:=TranslateDeFingers();
//OPTIONAL:BEST SET BY USER PROGRAM
TEMPLIST:=AY_Windows({320/2,Y0,320,200,0,200,320,220});
//AY_SetWin({320/2,Y0,320,100,0,20,20,22});
//END OPTIONAL
Fingerspell(WORLD);
//END ACCESSIBLE
//EXAMPLE USER SCREEN RESTORED
END;
EXPORT FINGERSPELLER_0_3()
BEGIN
//INSTALL(DEFAULT_INSTALL);
RESET();
OKC:=MSGBOX(CRID+"OK to Hello World
Esc to use",1);
IF OKC THEN
EXAMPLE_DEMO();
END;
FREEZE;
END;
FINGERSPELLER.HLP:
Code:
Fingerspeller V0.3 Help ©2016 StephenG1CMZ
FINGERSPELLER implements an accessibilty resource for the deaf and visually impaired, using AFiles. Fingerspelling graphics must be provided by the user (One per character).
On systems without access to host files, such as my Android, the visually impaired HUGE characters remain usable.
NO LIABILITY IS ACCEPTED.
ONLY THE 1st 2KB OF THIS HELPFILE IS VISIBLE FROM HELP. USE Notes.
Version 0.3 implements a simple A-Z/a-z character set.
A valid PPL LIST format Substitution list must exist. Characters to be substituted can be listed as ascii code (not unicode), or 1-character string (either ascii or unicode).
Eg: Render "(" as bracket, as open bracket, or ignore it?
COMMANDS
Fingerspeller_s: n
WAIT per character rendered
AY_Windows: {8 coordinates}
Always use two rectangles (graphic,text)
FingersLanguage: ""
Select an installed language
ICE_URGENT_MESSAGES:
Customise up to 2047 prepared messages
TranslateDeFingers
NOT IMPLEMENTED:Graphics to text
TranslateToFingers:
Translates (renders) input strings and files
TranslateFingers:
Translates (renders) in either direction
(see above)
Fingerspell: ""
Translate string parameter
CharImgSize: {x,y}
Size of your graphics images
INSTALL: string or {strings}
Installs languages ready for FingersLanguage. This can take a few seconds if building graphics.
A_TEST and HUGE graphics are used for this demo. For ASL and BSL:
USERS MUST PROVIDE OWN GRAPHICS!
RESET:
Resets these commands
FILES: AFiles or Notes
AY_TempG*: Temporary
FINGERSPELLERSL: Substitution list
FINGERSPELLER.HLP: This Text
ICE_URGENT_MESSAGES: List
<FingerLanguage>_A to _Z: Graphics
FAQs
Are MY graphics saved?
Yes, normal fingerspelling saves and restores for you=fingerspell,INSTALL.
But not Help or interaction=Translate...
Unicode?
Unicode can be recognised in the substitution list string. It cannot yet be rendered.
Troubleshooting
1 Input files exist.
2 If ABOUT will not fingerspell,
check the syntax of FINGERSPELLERSL.
Similarly check ICE_URGENT_MESSAGES.
Both are lists.
3 If instead of rendering Notes(name), you type in name- Program(name) will run!
BE CAREFUL NOT TO DELETE ALL.
HELP THE AUTHOR
Can anyone suggest either a source of graphics in HP ICON format, or a way of accessing the host filestore on Android?
StephenG1CMZ can provide software and systems testing to your requirements in several languages.
Example FINGERSPELLERSL:
Code:
{
{ 6,"ACK"},
{ 7,"BEL"},
{ 8,"BS"},
{ 21,"NAK"},
{ 33,"SHRIEK"},
{34,"QUOTES"},
{ 35,"HASH"},
{ 36,"DOLLAR"},
{ 37,"PERCENT"},
{ 38,"AMPERSAND"},
{ 39,"QUOTE"},
{ 40,"BRACKETS"},
{ 41,"BRACKETS"},
{ 42,"ASTERISK"},
{ 43,"PLUS"},
{ 44,"COMMA"},
{ 45,"MINUS"},
{ 46,"PERIOD"},
{ 47,"SLASH"},
{ 58,"COLON"},
{ 59,"SEMICOLON"},
{ 60,"LESS THAN"},
{ 61,"EQUALS"},
{ 62,"GREATER THAN"},
{ 63,"QUERY"},
{ 64,"AT"},
{ 91,"SQUARE BRACKET"},
{ 92,"BACKSLASH"},
{ 93,"SQUARE BRACKET"},
{ 94,"HAT"},
{ 95,"HYPHEN"},
{ 123,"BRACE"},
{ 124,"BAR"},
{ 125,"BRACE"},
{ 126,"APPROXIMATELY"},
{"0","ZERO"},
{"1","ONE"},
{"2","TWO"},
{"3","THREE"},
{"4","FOUR"},
{"5","FIVE"},
{"6","SIX"},
{"7","SEVEN"},
{"8","EIGHT"},
{"9","NINE"},
{ 127,"DEL"}
}
Example ICE URGENT MESSAGES:
Code:
{"SOS",
"EVACUATION"}
Hope this proves useful.
Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
|