Jump to content


Photo

Small message compressor


  • Please log in to reply
6 replies to this topic

#1 rogonow

rogonow

    GMC Member

  • GMC Member
  • 180 posts

Posted 05 January 2012 - 09:13 PM

Target
The compression is based on the removal of spaces between words.To keep the sentence parts separated, an alternating upper and lower case is assigned. If you think it is possible and useful to use the script in html5 for SMS, let me know then, pls. I use the script sometimes for composing SMS online.

Example of compression
"Worda wordb wordc WordD, worde. wordF" converts to "WORDAwordbWORDCwordd,WORDE.wordf"

Download page link

How to use
copy the text that you want compress
click on the program button or press "space" or "enter". If the color of the button changes, the converted text is then at the clipboard.

COMPRESSOR SCRIPT
//This script compresses a message without a decompressor needed to reed it.
//It alternates uppercase and lowercase and removes the spaces.
//Multiple lines, numbers and unextended ASCII code are supported.
//____________________________________________________________________________

//'³²²²³' is the reserved mark for this script.

//Treat undefined variables as '0' and use them only in this script
var a,hyperword,txt,txtp,maxi,compressed,stringcount;
//Exit script if there is no text on the clipboard or else assign the text from clipboard to 'txt'.
if clipboard_has_text()=false then exit else txt=clipboard_get_text();
//set the amount of sections of 'txt' to 'maxi'
maxi=string_count(' ',txt)+1;
//count up with 'stringcount' to the amount 'maxi' to treat 'txt' and text part 'txtp'
for (stringcount=1;stringcount<=maxi;stringcount+=1)
{
//mark the first space with mark '³²²²³' (because 'substr' of string_pos(substr,str) is always furthest)!
txt=string_replace(txt,' ','³²²²³')
//if there is no mark, then 'txtp' is assigned to the end else up to end mark
if string_pos('³²²²³',txt)=0 then 
txtp=string_copy(txt,1,string_length(txt))else
txtp=string_copy(txt,1,string_pos('³²²²³',txt)+4);
//check if first text part 'txtp' is already compressed and length of 'txtp' is larger than 35
if (stringcount=1 and string_length(txtp)>=35)
then {
//check if last character of long first part is lowercase. If so, switch 'a' is 1. Set 'hyperword' to 'txtp' 
if string_char_at(txtp,string_length(txtp)-5)=string_lower(string_char_at(txtp,string_length(txtp)-5)) then a=1;hyperword=txtp;}
else{
//if switch 'a' is on
if a=1 then
{//start odd 'stringcount':hyperword in 'lowercase', else 'hyperword' in uppercase
if floor(stringcount/2)<>(stringcount/2) then
hyperword=string_lower(txtp)else
hyperword=string_upper(txtp);
}
else
//start even 'stringcount':hyperword in 'lowercase', else 'hyperword' in uppercase
{if floor(stringcount/2)=(stringcount/2) then
//
hyperword=string_lower(txtp)else
hyperword=string_upper(txtp);
}}
//remove hyperword (+ mark eventually) of txt
txt=string_delete(txt,1,string_length(hyperword));
//remove mark of txt if aviable
hyperword=string_replace(hyperword,'³²²²³','');
//build up 'compressed' with the hyperword
compressed=string_insert(hyperword,compressed,string_length(compressed)+1);
};
//export string 'compressed'
clipboard_set_text(compressed);
//change image index if the conversion is successful.
if image_index=0 then {image_index=1;exit} else image_index=0;

Edited by rogonow, 06 January 2012 - 06:23 PM.

  • 0

#2 Artaex Media

Artaex Media

    Artaex Media

  • GMC Member
  • 1528 posts
  • Version:GM8

Posted 05 January 2012 - 09:23 PM

I don't see any use for this.

And what do you mean by "SMS"?
  • 0

#3 rogonow

rogonow

    GMC Member

  • GMC Member
  • 180 posts

Posted 05 January 2012 - 09:34 PM

I don't see any use for this.

And what do you mean by "SMS"?

If you don't know what SMS means, I understand then that you don't see the use for this.
More info about SMS is here.
  • 0

#4 piluke

piluke

    Pixel Matrix Member

  • GMC Member
  • 490 posts
  • Version:GM8

Posted 05 January 2012 - 11:32 PM

How are text messages related to HTML5?
  • 0

#5 rogonow

rogonow

    GMC Member

  • GMC Member
  • 180 posts

Posted 06 January 2012 - 07:02 PM

How are text messages related to HTML5?

I think HTML5 edition of GM supports the copy and paste of clipboard text.
I don't have the HTML5 edition of GM, but it would be nice if someone composes an application with the script with the HTML5 edition of GM. He/she could then provide the application on a html-file.
I can then save it then on my GSM to use it offline. I can copy (compressed) text and paste it in the normal window where SMS messages are composed on my GSM.

If I compress next sentence with 113 characters:

I don't have the HTML5 edition of GM, but it would be nice if someone composes the script with the HTML5 edition.

to in this case 92 characters:

Idon'tHAVEtheHTML5editionOFgm,BUTitWOULDbeNICEifSOMEONEcomposesTHEscriptWITHtheHTML5edition.



I have then (113-92)/113*100 % = 17 % extra space to type info for SMS.

Edited by rogonow, 06 January 2012 - 07:04 PM.

  • 0

#6 DanRedux

DanRedux

    GMC Member

  • GMC Member
  • 1332 posts
  • Version:GM:Studio

Posted 12 January 2012 - 09:32 PM

So spaces don't count. Pretty useful as it's the most commonly typed character.

However, how do you know when to use CAPITALS? What if the user wants to type, say, a username: TheSnidr.
  • 0

#7 rogonow

rogonow

    GMC Member

  • GMC Member
  • 180 posts

Posted 15 January 2012 - 08:17 PM

However, how do you know when to use CAPITALS? What if the user wants to type, say, a username: TheSnidr.

With the current script, the username will be converted to "thesnidr" or "THESNIDER".

The script can be modified to keep capital status: when the first letter of a word is a capital, the capital status could be kept and the space for it could be hold. But I didn't program that option. For the moment, you could adapt it manually.

Edited by rogonow, 16 January 2012 - 06:07 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users