Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. //is supposed to convert text from one physical keyboard layout to another
  2. bficontents = "";
  3. bficontents_1 = "";
  4. layout_qwerty = "1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
  5. layout_dvorak = "1234567890[]',.pyfgcrl/=\aoeuidhtns-;qjkxbmwvz";
  6. newline = "
  7. ";
  8. filename=get_open_filename("*","");
  9. if(filename==""){game_end();}
  10. fid = file_text_open_read(filename);
  11. while(!file_text_eof(fid)){
  12.   bficontents += file_text_read_string(fid)+newline;
  13.   file_text_readln(fid);
  14. }
  15.  
  16. //loop through each character of the text file.
  17. //replace characters of qwerty layour with ones of dvorak layout
  18. for(i=0;i<string_length(bficontents);i+=1){
  19.   currentchar = string_char_at(bficontents,i);
  20.   for(n=0;n<string_length(layout_dvorak);n+=1){
  21.     if(string_char_at(layout_dvorak,n)==currentchar){
  22.        currentchar=string_char_at(layout_qwerty,n);
  23.        break;
  24.     }else if(string_char_at(string_upper(layout_dvorak),n)==currentchar){
  25.        currentchar=string_char_at(string_upper(layout_qwerty),n);
  26.        break;
  27.     }
  28.   }
  29.   bficontents_1 += currentchar;
  30. }
  31. file_text_close(fid);
  32. fid=file_text_open_write(filename+"_out");
  33. file_text_write_string(fid, bficontents_1);
  34. file_text_close(fid);
  35. show_message("Finished reading, converting, saving.
  36. Length: "+string(i));
  37. game_end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement