Page 1 of 2

keeping the files alive

Posted: Sun Aug 23, 2015 7:07 am
by applePi
i have astonished yesterday to see a files posted in 2006 are still alive
it is great to keep the files alive for at least a century and even if the files downloaded only once per year. i know also other users keep their files alive such as luis, Danilo, ts-soft, Thalius, and many others. the code we post should not be only for August 2015 users but for many years ahead, and this is the spirit of the forum. i can't remember the user who asked many question and replied by many and after that he removed all his posts leaving the replies alone !!.

Re: keeping the files alive

Posted: Sun Aug 23, 2015 7:18 am
by Keya
there are a lot of uploads on other servers that no longer work :( it would be great if there was an official PB depository

Re: keeping the files alive

Posted: Sun Aug 23, 2015 7:21 am
by Shield
It's not official, but RS is doing a pretty good job. :)
http://www.rsbasic.de/backups/

Re: keeping the files alive

Posted: Sun Aug 23, 2015 7:32 am
by Keya
Shield, whoa! Lots there :) no update since January though

Re: keeping the files alive

Posted: Sun Aug 23, 2015 10:13 am
by Vera
Hello applePi,

yes many members are helping to keep PureBasic vivid. And now you could tune in too. :D

The posting that you've linked too offers code that relies on various files. Now one of them isn't available as it seems [Error 505] and that's the one needed for Linux.
Seeing that you'd replied in 2013 and telling about those files you might still have them yourself.
In this case it would be nice if you could bundle those three files from pebblesoft.com/RegExpServices/ and share a downloadlink on that thread.

And that's where RSBasic's backup service comes in, as he might share it as well. That's how it's meant to work ... to backup those files from the forums that got lost / became unaccessable over the time.

greets ~ Vera

Re: keeping the files alive

Posted: Sun Aug 23, 2015 10:33 am
by Vera
applePi wrote:this is the spirit of the forum. i can't remember the user who asked many question and replied by many and after that he removed all his posts leaving the replies alone !!.
I know members who are still active on this forum and didn't mind to devastate the german forum by deleting all postings before leaving for good.
And one of them raised himself to come across as moralist-guard of the board trying to bring down any topic or member that doesn't suit his points of view.

Not everyone who's bright shares sunshine.

Re: keeping the files alive

Posted: Sun Aug 23, 2015 1:22 pm
by RSBasic
I just updated my backup list. (+117 files)
But RegExpServices.pl could not be downloaded due an error. (500 - Internal server error)

\\Edit:
PerlRegularExpr.rar was added.

Re: keeping the files alive

Posted: Sun Aug 23, 2015 2:35 pm
by applePi
Vera is right the *.pl file are not available, sorry to make promotion for a false files, can't believe i have checked yesterday but may be only the exe and readme, usualy i run in Returnil virtual system so what i have download are disappeared unless storing them on other than "C:"
i have checked my oldest hard disk and here is the files , my test code run in PB v4.0 available from Museum near the end of your download account. i have saved the RegExpServices.exe file to purebasic\compilers . hope RSBasic add the pl file only
http://www.2shared.com/file/SPX5J_p4/Pe ... rExpr.html
Edit: no pl file available: look the post below

Re: keeping the files alive

Posted: Sun Aug 23, 2015 4:07 pm
by applePi
i began getting older, looking again at the files . for the windows users we need only the RegExpServices.exe and the RegExpServices.pb which are listed and updated in the purebasic page and it works in PB 5.31 . the RegExpServices.exe file are made from perl file : RegExpServices.pl but RegExpServices.pl are not posted from 2006 it is just listed it is needed for the Linux users. the secret of the RegExpServices.exe is in RegExpServices.pl and it is not available. i can't delete my quote: the history should stay as it is.

Re: keeping the files alive

Posted: Sun Aug 23, 2015 8:45 pm
by Vera
Oh well - it was a try ... and thanks for checking.

You might not have downloaded the RegExpServices.pl if you had no need for it back then.
I did some research on the waybackmachine but there had never been a link published to that specific directory so that page was never scanned.

But maybe someone else had downloaded it and will share it if asked ... and we could finalize this incidental small project.

Re: keeping the files alive

Posted: Mon Aug 24, 2015 1:31 pm
by applePi
Vera, i have found this purebasic + perl code on my old drive, in fact i forgot almost all the tricky syntax of perl. but using my test Pattern and string in http://purebasic.fr/english/viewtopic.p ... 25#p144062 it produce the same result:
i don't know if it works in Linux (RunProgram("perl.???".. so edit it and try since the perl installed by default in Linux: check its version with perl -v . i have perl 5.14 installed on my windows ,and haven't used it from years

PB code:

Code: Select all

console.l = RunProgram("perl.exe"," regReplace.pl","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write) 

For i=1 To 50

If AvailableProgramOutput(console) 
 s.s = s.s + "    " + ReadProgramString(console) 

EndIf 

Delay(10) 
Next i
Debug s
perl code : name it as regReplace.pl

Code: Select all

#/user/bin/perl

#$string = 'The cat sat on the mat';
$string = 'raab rdaab saabg fkaab saabv';
#$string =~ s/cat/dog/;
$string =~ s/(?<!d|k)aab/x/g;

print "Final Result is $string\n";
note that in s/(?<!d|k)aab/x/g; the /g is for global searching all the string
you can see that the output are directed to purebasic Debug windows
i think it is possible to deliver the input from purebasic to perl with WriteProgramData()
but since i may spend too much time in checking WriteProgramData, i provide the what is available now.

Re: keeping the files alive

Posted: Mon Aug 24, 2015 4:39 pm
by applePi
i have failed to use WriteProgramStringN and sisters but can deliver the sentence to perl like this:
words.s = "raab rdaab saabg fkaab saabv"
RunProgram("perl.exe ", "regReplace.pl" + " " + words

then perl get the string from console with @ARGV as an array, it is an array of words and one way to join it using join function

purebasic code:

Code: Select all

Define words.s
words = "raab rdaab saabg fkaab saabv"
console.l = RunProgram("perl.exe ", "regReplace.pl" + " " +words,"",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write) 

For i=1 To 50

If AvailableProgramOutput(console) 
 s.s = s.s + "    " + ReadProgramString(console) 

EndIf 

Delay(10) 
Next i
Debug s
perl code regReplace.pl

Code: Select all

#/user/bin/perl

@str = @ARGV;
$string =  join(" ", @str);
print "the string is $string\n";
$string =~ s/(?<!d|k)aab/x/g;
print "Final Result is $string\n";

references:
looking at Processing command line arguments - @ARGV in Perl
http://perlmaven.com/argv-in-perl
http://www.tutorialspoint.com/perl/perl ... ession.htm

Re: keeping the files alive

Posted: Tue Aug 25, 2015 4:04 pm
by Vera
Hi applePi,
thanks for you examples. I got it running and the output is debugged.

As perl is in the path I can run it alike you with:

Code: Select all

RunProgram("perl"," regReplace.pl","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write)
Great - this way I could create my own *.pl-files, let them run and catch the outputs
Not sure atm if that really makes much sense, but I much appreciate this new opened door to experience Perl directly.
Maybe that helps me to find out what PB demands as a working regex-syntax.

This referes to your first reply ... the second one just came up when I logged in and I'll look into it as of next.


Addendum:
To pass on a string via @ARGV and join is good to know and it also allows to send a whole file in that way 8)

I too tried a while with WriteProgramStringN(), but know think it's maybe only working with programs that have a kind of input-interface like e.g. the console.

On a sidenote - I wondered why you'd used that 1-50 loop as it also debugs fully with this methode:

Code: Select all

console = RunProgram("perl", paras$, path$, #PB_Program_Open| #PB_Program_Read| #PB_Program_Write)

While ProgramRunning(console)
  If AvailableProgramOutput(console)
    Debug ReadProgramString(console) 
  EndIf
Wend
CloseProgram(console) 
And thank you for those links ~ esp. the condensed overview of the reg-expressions :-)

Re: keeping the files alive

Posted: Wed Aug 26, 2015 8:25 am
by applePi
Vera writes:
I wondered why you'd used that 1-50 loop
at first don't forgot that bfitch have posted his .pl file as zip file look http://purebasic.fr/english/viewtopic.p ... 25#p469648
the 50 loops is because i have used this code to call Factor.exe from shamus sotware now available only from web.archive.org 2007 nov
http://web.archive.org/web/200711181716 ... factor.exe
there is also variations here: http://home.netcom.com/~jrhowell49/math/software.htm search word shamus. but i prefer the original version from year 2007 in archive.org
it is needed to wait the outputs of Factor.exe one by one, we may need 50 or more or less but now i recognize that While ProgramRunning(console) are better choice.
beware of numbers made from 2 very big prime numbers like used in the Banks the factor.exe may stay running for days.
here is the code for calling the factor.exe with a specific number using your loop version

Code: Select all

console.l = RunProgram("factor.exe"," -s 111111111111111111111111","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write) 

While ProgramRunning(console)
If AvailableProgramOutput(console) 
 s.s = s.s + "    " + ReadProgramString(console) 

EndIf 

Delay(10) 
Wend
Debug s
i have found also on my old pc unexpected code seems strange to me and it contains even Goto function, it display the outputs of factor.exe to EditorGadget. so the same program can be adapted for calling perl to do regular expressions (or whatever) and returning the results back to EditorGadget, definitely i have copied parts of it from this forum (except Goto which are mostly from me), i provide it as it is. just put factor.exe in the same folder as the code
try number 11111111111111111111111111111111111111111111111111111111111
and it will factor it to 2559647034361 * 4340876285657460212144534289928559826755746751
we can check the results with http://www.wolframalpha.com/ just write: factors of 11111111111111111111111111111111111111111111111111111111111
Edit: look here the post of klonk : http://forums.purebasic.com/english/vie ... p?p=137416

Code: Select all

;{ ========================================================================== 
;|  EndProgram(processID.l) 
;|    Closes the application that was started with RunProgram. In difference 
;|    to KillProgram it allows the program to shut down properly and save e.g. 
;|    settings. The parameter "processID" is obtained by ProgramID(<result of 
;|    RunProgram(app$,option$,path$, #PB_Program_Open)>) 
;} ========================================================================== 
Procedure EndProgram(processID.l) 
;***** End a program started with Runprogram, but give chance to save settings! 
  If OpenProcess_(#PROCESS_ALL_ACCESS,0,processID)<>0 
    CloseHandle_(processHandle) 
    Repeat ;searcht through all windows 
      win=FindWindow_(0,0) 
      While win<>0 
        GetWindowThreadProcessId_(win,@pid.l) ; get processID of found window 
        If pid=processID : WinHandle=win : Break : EndIf 
        win=GetWindow_(win,#GW_HWNDNEXT)
        Delay(100) 
      Wend 
    Until WinHandle 
    PostMessage_(WinHandle,#WM_CLOSE,0,0) ; Now close the started application 
  EndIf 
EndProcedure 

Procedure factorize(number$)
s.s
number$ = " -d200 "+" -s "+number$ 

handle.l = RunProgram("factor.exe",number$,"",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide) 
id.l = ProgramID(handle) 

waitTime.l=20000  ;20000 milliseconds

Result = WaitProgram(handle.l,waitTime)
If Result=0
  s = "the factoring time will exceed the waitTime specified, the process is halted    "
 CloseProgram(handle) 
 Sleep_(2000) ; Give it a couple of seconds to open. 
 EndProgram(id);End started program
 Goto jmp
EndIf
While AvailableProgramOutput(handle)
   s = s + ReadProgramString(handle) + "  *  "

Delay(10) 

Wend
jmp:
s = Mid(s,1,Len(s)-4)
;SetGadgetText(0, s)
AddGadgetItem(0, -1, s+Chr(13)+Chr(10))
EndProcedure
If OpenWindow(0,0,0,550,460,"numbers factoring",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 10, 230, 380, 210)
SendMessage_(GadgetID(0), #EM_SETTARGETDEVICE, #Null, 0)
StringGadget(1, 10, 80, 380, 60, "write number here", #PB_String_Numeric |#ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT | #ES_MULTILINE | #ES_AUTOVSCROLL | #WS_VSCROLL )
ButtonGadget(2, 420, 400, 120, 40, "Factorize" ) 
Repeat 
  Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
         Case 2 :
             number$ = GetGadgetText(1)
             factorize(number$) 
         EndSelect
      EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
     

Re: keeping the files alive

Posted: Wed Aug 26, 2015 10:04 pm
by Vera
applePi wrote:at first don't forgot that bfitch have posted his .pl file as zip
YEAH ~ I got it ... and your test example now also runs successfully on Linux :-)
(after I had figured out that the older include from your package needed an update with the current include from the thread).
It's really great how quickly this had been solved. 8)

Thanks for your discours to factoring. I have no doubt that it's a thrilling subject, but let me reply with a quote:
Jim Howell wrote:"That may give you a very general idea of what is going on with NFS factoring, depending on how much of that you understand. "
:mrgreen:
the same program can be adapted for calling perl to do regular expressions (or whatever) and returning the results back to EditorGadget
I think you'd be quicker writing a new code as you're not only sending a number but an expression and text and you might need to create *.pl-files. ... but don't be stopped to go for it.

Only recently I've understood how to run bash commands and capture the outputs and am currently working on a small app displaying the running processes.... while I'm trying to find a way, how I could find and address other running programs.
... just reinventing wheels I guess ;-)