Version 0.2 has an improved API demonstrating support for multiple languages.
Note that you should run the Hello World example - otherwise other routines may not be initialised.
Code:
LOCAL VERNUM:=0.2;
LOCAL CRID:="FINGERSPELLER © 2016 StephenG1CMZ"+CHAR(10);
//SHOWS CURRENT LANGUAGE. USERS USE FingersLang() FUNCTION
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 MYHELP:="FINGERSPELLER.HLP";
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 EXPORT THESE MESSAGES
//EXPORT ICE_URGENT_MESSAGE;
LOCAL ICE_URGENT_MESSAGE:={
"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";
//HP COMMON
LOCAL IMP_LIMIT_PRINT:=2000;
LOCAL ZTypeNUMERIC:=0;
LOCAL ZTypeSTRING:=2;
LOCAL ZTypeLIST:=6;
//END HP COMMON
JUNKA(FS)
BEGIN
IF SIZE(FS) THEN //PRECAUTION
DelAFiles(FS);//Garbage Gone
END;
END;
SCR_PUT()
BEGIN
AFiles(FSTMP+"G0"):=G0;//SAVE
AFiles(FSTMP+"G7"):=G7;
END;
SCR_GET()
BEGIN
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;
DO_FSPELL(ST,TOPCALL)
//AVOID SCREENSAVING HERE
//IDEALLY: EARLY COMPLETION TBD
BEGIN
LOCAL CH;
LOCAL II;
//ESCAPE IF GETKEY4 AND SECS≠0?TBD
FOR II FROM 1 TO DIM(ST) DO
CH:=UPPER(MID(ST,II,1));
IF TOPCALL THEN
//DEMONSTRATE REPLACEMENT:USE A TABLE LATER
IF CH=="©" THEN
DO_FSPELL("COPYRIGHT",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
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","Enter File to Fingerspell EG: Notes(string) "};
LOCAL ST:={};
OKC:=INPUT({{STRNG,[2]},{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;
// USER INTERFACE API
// AY=ACCESSIBILITY
// ----------------
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;
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
//NB WHEN THE PROGRAM IS RE-RUN STRINGS ARE RESET!
BEGIN
//LOCAL INSTRS:={"To edit list:","ICE_URGENT_MESSAGE:={strings}"};//ONLY WHEN EXPORT
OKC:=CHOOSE(CHS,"Select Message to Fingerspell",ICE_URGENT_MESSAGE);
IF OKC THEN
IF CHS>0 THEN
PRINT();
PRINT(ICE_URGENT_MESSAGE(CHS));
Fingerspell_ST(ICE_URGENT_MESSAGE(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;
HELP()
BEGIN
LOCAL ST:=Notes(MYHELP);
DEBUG;
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
RECT_P();
TEXTOUT_P(CRID,0,20);
TEXTOUT_P(VERNUM,0,40);
WAIT(1);
//DEBUG;
Fingerspell_ST(CRID);
WAIT;
END;
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 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 FILEPECS
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;
//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_2()
BEGIN
OKC:=MSGBOX(CRID+"OK to Hello World
NB DO THIS 1st",1);
//OMITING THE SETUP WITHIN THE DEMO
//LEAVES SOME VITAL STUFF NOT INITIALISED
//FIX TBD
IF OKC OR 1 THEN
EXAMPLE_DEMO();
END;
FREEZE;
END;