Share your advanced PureBasic knowledge/code with the community.
Konne
Enthusiast
Posts: 434 Joined: Thu May 12, 2005 9:15 pm
Post
by Konne » Wed Jan 17, 2007 6:20 pm
Code updated for 5.20+
This Program displays itsself in the debugger. Maybe someone can make it smaller.
Code: Select all
C.s="C.s=#:C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)):Debug C":C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)):Debug C
Apart from that Mrs Lincoln, how was the show?
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Wed Jan 17, 2007 7:06 pm
waaahouuu that's so strange
what the use for such code ?
how it works ? i didn't understand at all your logic...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Derek
Addict
Posts: 2354 Joined: Wed Apr 07, 2004 12:51 am
Location: England
Post
by Derek » Wed Jan 17, 2007 7:20 pm
That's clever.
Henrik
Enthusiast
Posts: 404 Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark
Post
by Henrik » Wed Jan 17, 2007 8:25 pm
lol
cool
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Wed Jan 17, 2007 8:35 pm
Wow!
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Posts: 434 Joined: Thu May 12, 2005 9:15 pm
Post
by Konne » Wed Jan 17, 2007 11:02 pm
Flype wrote:
what the use for such code ?
Normally you would think this would be a Infinity Recursive problem.
You may think it's impossible to make a Quote of a Quote etc
But thanks to Stringmanipulation it's possible
Once you understand the concept you have to make the program smaller. The one making the smallest PB Program wins
Apart from that Mrs Lincoln, how was the show?
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Wed Jan 17, 2007 11:07 pm
It nearly sent me crackers trying to figure out what the hell was going on!
It is very clever.
I may look like a mule, but I'm not a complete ass.
Tommeh
Enthusiast
Posts: 149 Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom
Post
by Tommeh » Thu Jan 18, 2007 2:57 am
Ok, as we seem to be using PB hacks :p here is one for you
Code: Select all
String$ = "hello" ;String is defined
String$ = "world" ;String is redefined with new value
!MOV edx,dword _S1
!MOV [v_value],edx
Debug PeekS(value, 5) ;Get previous value
Debug PeekS(value+6, 5) ;Get new value
You can also use this method to retreve defined variable names and values :p
Konne
Enthusiast
Posts: 434 Joined: Thu May 12, 2005 9:15 pm
Post
by Konne » Thu Jan 18, 2007 1:54 pm
It's not at all a PB Hack.
It's understandable with a couple of comments and the replacement of :'s.
Code: Select all
C.s="C.s=#:C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)):Debug C" ;We save the Code in this Variable. # is then Replaced with " +Code +"
C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)) ;Here we Replace # (Chr(35)) with the Code.And Two " (Chr(34))
Debug C ;Here we debug the Code
Apart from that Mrs Lincoln, how was the show?
Rook Zimbabwe
Addict
Posts: 4322 Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:
Post
by Rook Zimbabwe » Wed Jan 24, 2007 7:37 am
C.s="C.s=#:C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)):Debug C":C=ReplaceString(C,Chr(35),Chr(34)+C+Chr(34)):Debug C
OK keep in mind I am dense! but that is what pops up in debug... Oy I feel stupid for asking but that is what is
Supposed to happen???
JCV
Enthusiast
Posts: 580 Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines
Post
by JCV » Wed Jan 24, 2007 2:21 pm
1st kind of code to see in pb.
#NULL
Addict
Posts: 1499 Joined: Thu Aug 30, 2007 11:54 pm
Location: right here
Post
by #NULL » Mon Apr 18, 2016 2:45 pm
Konne wrote: This Program displays itsself in the debugger. Maybe someone can make it smaller.
i once posted one in the german forum:
http://forums.purebasic.com/german/view ... f=8&t=8471
apparently its 3 characters shorter
and there are still 4 spaces that can be eliminated..
Code: Select all
s$="s$=:Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)":Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)
Demivec
Addict
Posts: 4270 Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA
Post
by Demivec » Mon Apr 18, 2016 7:31 pm
#NULL wrote: Konne wrote: This Program displays itsself in the debugger. Maybe someone can make it smaller.
i once posted one in the german forum:
http://forums.purebasic.com/german/view ... f=8&t=8471
apparently its 3 characters shorter
and there are still 4 spaces that can be eliminated..
Code: Select all
s$="s$=:Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)":Debug Mid(s$,1,3)+Chr(34)+s$+Chr(34)+Mid(s$,4,100)
This code is shorter by 11 more characters (under 100)
.
Code: Select all
s.s="s.s=:Debug Mid(s,1,4)+Chr(34)+s+Chr(34)+Mid(s,5)":Debug Mid(s,1,4)+Chr(34)+s+Chr(34)+Mid(s,5)
wilbert
PureBasic Expert
Posts: 3942 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Mon Apr 18, 2016 8:07 pm
Left will make it two chars shorter
Code: Select all
s.s="s.s=:Debug Left(s,4)+Chr(34)+s+Chr(34)+Mid(s,5)":Debug Left(s,4)+Chr(34)+s+Chr(34)+Mid(s,5)
Windows (x64)
Raspberry Pi OS (Arm64)