Jump to content



Photo
- - - - -

Porting A Lua Program From Cp To 9860


  • Please log in to reply
5 replies to this topic

#1 JackZhan

JackZhan

    Newbie

  • Members
  • Pip
  • 9 posts
  • Gender:Male

  • Calculators:
    fx-82ES
    fx-5800P
    fx-9750GII (Hacked)
    TI-83

Posted 24 May 2012 - 01:20 PM

Hey everyone, I have just discovered a chemical equation balancer on the CPlua. As the lua for 9860 have been released, shall we think about porting it to 9860? I can't open the .mcs file cause the CP MCS editor program doesn't work on my PC. May be someone give me the source code please?

#2 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 24 May 2012 - 02:18 PM

Here is the source code written by vanhoa extracted from the mcs file.

But make sure to fully read the disscussions in that thread.

But what was wrong with the CP MCS Editor? I saw no problems. :huh: Please tell me in its topic: http://www.casiocalc...?showtopic=6771

require("string","cas","table") function ucln(a,B) if(b%a==0) then return a else return ucln(b%a,a) end end function del1(a) if(a==1) then return "" else return a end end function duavedangcoban(s) i=1 s=string.gsub(s,"%(%-%)","%(%-1%)") s=string.gsub(s,"%((%-)([0-9]+)%)","Aientich%2") s=string.gsub(s,"%(%+%)","%(%+1%)") s=string.gsub(s,"%((%+)([0-9]+)%)","Dientich%2") s=string.gsub(s,"%+","%)%+%(") s="val_1*("..s s=string.gsub(s,"%+",function (s) i=i+1 return "+val_"..i.."*" end) s=string.gsub(s,"%=","%)%=%(") s=string.gsub(s,"%=",function (s) i=i+1 return "=val_"..i.."*" end) s=string.gsub(s,"(%u%l*)([0-9])","%1*%2") s=string.gsub(s,"(%u)","+%1") s=string.gsub(s,"%(","+%1") s=string.gsub(s,"%(%+","%(") s=string.gsub(s,",%+",",") s=string.gsub(s,"(%))([0-9])","%1*%2") s=string.gsub(s,"%*%+","%*") s=string.gsub(s," ","") s=string.gsub(s,"%(%+","%(") s=tostring(cas.expand(s..")|Dientich=-Aientich")) return s,i end function getval(sf) local val,s,i={},sf,1 for w in string.gmatch(s,"%u%l+") do val[i]=w s=string.gsub(s,val[i],"") i=i+1 end for w in string.gmatch(s,"%u") do val[i]=w i=i+1 end i=1 table.sort(val) while(i<#val) do if(val[i]==val[i+1]) then table.remove(val,i) else i=i+1 end end return(val) end function canbang(ss,pri) local s,numval=duavedangcoban(ss) local gv=getval(s) local strgv="|"..table.concat(gv,"=0|").."=0" local func="solve({" for i=1,#gv,1 do func=func..cas(s.."|"..tostring(gv[i]).."=1"..strgv) if i~=#gv then func=func.."," else func=func.."}," end end func=func.."{" for i=1,#gv,1 do func=func.."val_"..i if i~=#gv then func=func.."," else func=func.."})" end end if(#gv<numval) then for i=#gv+1,numval,1 do func=func.."|val_"..i.."=87297210" end end func=string.gsub(func,"=0","=87297210") local kq=tostring(cas.getright(func)) kq=string.gsub(kq,"val_[0-9]","87297210") kq=string.gsub(kq,"î","%*") local sqk dostring("skq="..kq) local uc=skq[1] for i=2,#skq,1 do uc=ucln(uc,skq[i]) end ss=string.gsub(ss,"%(([%+%-])([0-9]*)%)",function(a,B) a=string.gsub(a,"%+","%íú") a=string.gsub(a,"%-","%íû") b=string.gsub(b,"1","íñ") b=string.gsub(b,"2","íò") b=string.gsub(b,"3","íó") b=string.gsub(b,"4","íô") b=string.gsub(b,"5","íõ") b=string.gsub(b,"6","íö") b=string.gsub(b,"7","í÷") b=string.gsub(b,"8","íø") b=string.gsub(b,"9","íù") b=string.gsub(b,"0","íð") return(b..a) end) ss=string.gsub(ss,"0","ìð") ss=string.gsub(ss,"1","ìñ") ss=string.gsub(ss,"2","ìò") ss=string.gsub(ss,"3","ìó") ss=string.gsub(ss,"4","ìô") ss=string.gsub(ss,"5","ìõ") ss=string.gsub(ss,"6","ìö") ss=string.gsub(ss,"7","ì÷") ss=string.gsub(ss,"8","ìø") ss=string.gsub(ss,"9","ìù") i=1 ss=del1(skq[1]/uc)..ss ss=string.gsub(ss,"%+",function (s) i=i+1 if (i>#skq) then return "+"..del1(87297210/uc) else return "+"..del1(skq[i]/uc) end end ) ss=string.gsub(ss,"%=",function (s) i=i+1 if (i>#skq) then return "="..del1(87297210/uc) else return "="..del1(skq[i]/uc) end end ) ss=string.gsub(ss," ","") if pri then print(ss) end return(ss) end 
 export{cb=canbang}


#3 veb

veb

    Casio Fan

  • Members
  • PipPip
  • 43 posts

Posted 24 May 2012 - 03:31 PM

I think it will be difficult to convert it, since some of the functions in this code aren't on fx 9860: there is no cas functions and neither string.gsub

#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 26 May 2012 - 01:48 AM

maybe we could make some cas functions...

also, why are there no line breaks in any of the CPLua code i have seen? does it make the file size smaller or is it some sort of optimization?

#5 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 26 May 2012 - 10:37 AM

You can feel the lack of line breaks in a few of vanhoa's latest programs, and he did it to make smaller programs, but the rest of the programs are formatted and indented.
Open any of them with the CP MCS Editor and watch for yourself. I still don't know why it didn't work for JackZhan?

#6 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 26 May 2012 - 12:15 PM

maybe we could make some cas functions...

also, why are there no line breaks in any of the CPLua code i have seen? does it make the file size smaller or is it some sort of optimization?


Probably and optimization added before it is sent to the calc; in an editor, it may have formatting.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users