forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Some string manipulation functions...
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Sep 07, 2002 2:45 pm    Post subject: Reply with quote

This is an example of the 'Secret Language' that some little children use, in other words: 'hello world' will be translated into 'ifmmp xpsme'.

Code:

%%String = abcdefghijklmnopqrstuvwxyz
rem This number can higher than 26
%%Charactersup = 27

gosub Characterup

info %%String
exit

:Characterup
if @greater(%%Charactersup,26)
  repeat
  %%Charactersup = @diff(%%Charactersup,26)
  until @greater(26,%%Charactersup)
  end
%z = 0
repeat
if @not(@greater(@fadd(@asc(@substr(%%String,%z,%z)),%%Charactersup),@asc(z)))
  if @not(@equal(@asc(@substr(%%String,%z,%z)),32))
    %%String = @strins(@strdel(%%String,%z,%z),%z,@chr(@fadd(@asc(@substr(%%String,%z,%z)),%%Charactersup)))
   else
   %%String = @strins(@strdel(%%String,%z,%z),%z,@chr(32))
   end
  else
    if @not(@equal(@asc(@substr(%%String,%z,%z)),32))
    %%String = @strins(@strdel(%%String,%z,%z),%z,@chr(@diff(@fadd(@asc(@substr(%%String,%z,%z)),%%Charactersup),26)))
     else
   %%String = @strins(@strdel(%%String,%z,%z),%z,@chr(32))
   end
  end
%z = @succ(%z)
until @equal(@pred(%z),@len(%%String))
exit
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Sep 07, 2002 4:07 pm    Post subject: Reply with quote

LOL, "pig latin" anyone? Laughing
Code:

rem -- Use @trim() on unknown strings --
%%tmp = "this is a test"

OPTION FIELDSEP, @chr(32)
REPEAT
  PARSE "%a", %%tmp
  %%tmp = @strdel(%%tmp, 1, @succ(@len(%a)))
  %s = %s@substr(%a, 2, @len(%a))" "@substr(%a, 1)ay" "
UNTIL @greater(1, @len(%%tmp))
INFO %s


Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Sep 07, 2002 6:54 pm    Post subject: Reply with quote

His tay s iay aay est tay??
Well, if pigs speak like that, isn't it better if they go to school??? Smile
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Sep 07, 2002 7:21 pm    Post subject: Reply with quote

LOL skit, Laughing

I guess for it to be "proper" pig latin, it should treat
dual letters that make one sound (such as "th", "ch",
etc.) as a single letter.

For example, "this" should prolly be "is thay". It just
didn't really seem worth the trouble... Razz

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Sep 07, 2002 7:27 pm    Post subject: Reply with quote

I can't get enough of all these String manipulate functions. Smile

Code:

%%Reverse = "This is a test"
gosub Reverse-wfw
info %%Reverse
exit

:Reverse-wfw
option fieldsep,@chr(32)
repeat
  parse "%%word",%%Reverse
  %%Reverse = @strdel(%%Reverse,1,@succ(@len(%%word)))
  if @not(@equal(%%justavariable,))
    %%justavariable = %%justavariable" "
   end
  if %%word
    repeat
    %%justavariable = %%justavariable@substr(%%word,@len(%%word),@len(%%word))
   %%word = @strdel(%%word,@len(%%word),@len(%%word))
   until @greater(1,@len(%%word))
   end
until @greater(1,@len(%%Reverse))
%%Reverse = %%justavariable
exit


Ps. Does anybody have an idea for another one?
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Sep 07, 2002 7:54 pm    Post subject: Reply with quote

OK, here's a more grammatically correct "pig latin" example... Razz

Feel free to add more stuff to list 1 and 2 (or to the code). Wink
Code:

rem -- Use @trim() on unknown strings --
%%tmp = "this is a serious test"

rem -- Some starting letter pairs that make one sound --
LIST CREATE, 1
LIST ADD, 1, "th"
LIST ADD, 1, "ch"
LIST ADD, 1, "ph"

rem -- Some two letter words starting with a vowel --
LIST CREATE, 2
LIST ADD, 2, "at"
LIST ADD, 2, "if"
LIST ADD, 2, "is"
LIST ADD, 2, "of"
LIST ADD, 2, "on"

OPTION FIELDSEP, @chr(32)
REPEAT
  LIST SEEK, 1, 0
  LIST SEEK, 2, 0
  PARSE "%a", %%tmp
  rem -- Starting with letter pair --
  if @match(1, @substr(%a, 1, 2))
     %s = %s@substr(%a, 3, @len(%a))" "@substr(%a, 1, 2)ay" "
  else
     rem -- Single letter word, or two letter word starting with vowel --
     if @equal(@len(%a), 1) @both(@equal(@len(%a), 2), @match(2, %a))
        %s = %s%a" "ay" "
     else
        %s = %s@substr(%a, 2, @len(%a))" "@substr(%a, 1)ay" "
     end
  end
  %%tmp = @strdel(%%tmp, 1, @succ(@len(%a)))
UNTIL @greater(1, @len(%%tmp))
INFO %s

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Sep 07, 2002 8:10 pm    Post subject: Reply with quote

Next thing to make: a pig spell-checker??? Smile
Oops... I made something like that already for Serge:

Code:

 dialog CREATE,Spell checker,-1,0,541,253
  dialog ADD,EDIT,TEXT,22,20,318,182,hllo hwo are you tody in ameriiica,MULTI,WRAP,SCROLL
  dialog ADD,BUTTON,BUTTON1,210,18,64,24,Spellcheck
  dialog ADD,BUTTON,BUTTON2,180,344,180,24,No suggestion
  dialog ADD,LIST,SUGGESTIONS,36,344,180,138,SORTED,CLICK
  dialog ADD,TEXT,word,22,346
  dialog ADD,MENU,-,ENTER|ENTER
  dialog SHOW
  list add,SUGGESTIONS

  list create,1
  list loadtext,1,sorted
"
"hello
"america
"hi
"hill
"hull
"how
"who
"ho
"tod
"toady
"today
"todd


:evloop
  wait event
  %%event = @event()
  goto %%event

:Button1button
  %%text = @trim(@dlgtext(TEXT))
  option fieldsep,@chr(32)
  %%chr32pos = @pos(@chr(32))

:spellcheckloop
  parse "%%word",%%text
  dialog set,word,%%word
  %%text = @strdel(%%text,1,@succ(@len(%%word)))

  list seek,1,0
  list seek,SUGGESTIONS,0

  if @equal(@item(SUGGESTIONS,0))
    list delete,SUGGESTIONS
  end

rem %x countains the number off suggestions

%x = 5

repeat
if @greater(%x,0)
  %z = 0
  repeat
    if @match(1,@substr(%%word,%z,@fadd(%z,2)))
      if @not(@match(SUGGESTIONS,@item(1)))
        list add,suggestions,@item(1)
      end
    end
    %z = @succ(%z)
  until @equal(%z,@len(%%word))
  end
  %x = @pred(%x)
until @equal(%x,0)

  wait event
  %%event = @event()

  if @equal(%%event,SUGGESTIONSCLICK)
    %%newtext = %%newtext @item(SUGGESTIONS)
    dialog set,text,@trim(%%newtext %%text)
    list clear,SUGGESTIONS
    list add,SUGGESTIONS
    if @not(@null(%%text))
      goto spellcheckloop
    end
  end

  if @equal(%%event,Button2button)
    %%newtext = %%newtext %%word
    dialog set,text,@trim(%%newtext %%text)
    list clear,SUGGESTIONS
    list add,SUGGESTIONS
    if @not(@null(%%text))
      goto spellcheckloop
    end
  end

  if @equal(%%event,close)
    goto Close
   end
   
  %%text =
  %%newtext =
  %%word =
  goto evloop

:Button2button
  rem Only works if the spell-checker is activated...
  goto evloop

:Entermenu
  warn "This is disable. Make the script to work with @cr()@chr(10)"
  goto evloop

:Close
  exit
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group