Python Forum
[split] Is there some coding that will do the following in 3 separate events?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Is there some coding that will do the following in 3 separate events?
#11
(Jul-19-2021, 07:34 PM)Yoriz Wrote: Are you looking to automate other software?
Something like pywinauto or PyAutoGUI

We are trying to create a User Library in CodeIgniter. Initially we thought that we should integrate a simple text editor macro system, by using Python, similar to that contained in UltraEdit32, & must say that UltraEdit32 system is very comprehensive & will do anything we want automatically, but after some investigation we found the following;

Does Python have macro? -The programming language of Python does not have built-in support for macros unlike many other languages such as C [2] or Racket [3].17 Dec 2018
https://scholarworks.sjsu.edu/cgi/viewco...d_projects

So we moved into C++ & found this;

https://www.ibm.com/docs/en/ztpf/1.1.0.1...ro-support
C/C++ preprocessor macros are not supported by the Systems/C and Systems/C++ compilers.
However that is not the end, as the compilers used in C++ are separate from the language itself.
We have submitted the idea of creating a macro system in the C++ forum but guess that is likely to be too much to ask for.
But if we were to go down that track we would need to integrate the C++ language into CodeIgniter, which in itself would be likely to create further problems & maybe beyond our capabilities.

UltraEdit32 & Sublime text are built in C++ so we thought that our simple idea would be solved but it has become very complicated.

The basic functions we want is to Select & Copy contents from one text file then Paste & Save it into another text file. UltraEdit32 can do that with ease, but we cant get CodeIgniter & UltraEdit32 to work together, via users of the website.

Because CodeIgniter already does use Python we have come back to Python in the hope that we can at least get the basics, Select, Copy, Paste & Save working.

Hey, who was that calling me a "Silly Frenchman"? Im Australian.
Reply
#12
(Jul-19-2021, 06:11 PM)bensan Wrote: We are building a website using CodeIgniter & PHP where the former has limitations. The GUI would be a browser. CodeIgniter has the capability of opening & closing text files, & our system has created a file containing ONLY a text link, so we need a facility that will open the text file, (1) select the contents (2) copy the contents. - Close the file & Open another - (3) paste the clipboard contents. - Save & close the file. Im not sure if CodeIgniter would save upon closing but we can investigate that if & when we get the Select, Copy & Paste working. CodeIgniter already uses Python.

You make this sound like the clipboard is needed, not sure why you would not simply open a file, copy the contents to a string object, close, open the second file in write (or append) mode and write the contents of the string object to the second file (then close). Would this not work?
Reply
#13
(Jul-20-2021, 11:36 AM)jefsummers Wrote:
(Jul-19-2021, 06:11 PM)bensan Wrote: We are building a website using CodeIgniter & PHP where the former has limitations. The GUI would be a browser. CodeIgniter has the capability of opening & closing text files, & our system has created a file containing ONLY a text link, so we need a facility that will open the text file, (1) select the contents (2) copy the contents. - Close the file & Open another - (3) paste the clipboard contents. - Save & close the file. Im not sure if CodeIgniter would save upon closing but we can investigate that if & when we get the Select, Copy & Paste working. CodeIgniter already uses Python.

You make this sound like the clipboard is needed, not sure why you would not simply open a file, copy the contents to a string object, close, open the second file in write (or append) mode and write the contents of the string object to the second file (then close). Would this not work?

Thanks @jefsummers - Ive numbered your comments
(1) You make this sound like the clipboard is needed
(2) open a file, copy the contents to a string object
(3) open the second file in write (or append) mode
(4) write the contents of the string object to the second file
(5) Would this not work?

(1) Yes, a clipboard will be needed but Im unsure how that will work e.g. what if a 2nd person clicked the same facility before the 1st person pasted.
(2) I dont know how to copy the contents to a string object. Can you explain?
(3) CodeIgniter does open in fwrite append.
(4) I dont know how to write the contents of the string object. Can you explain?
(5) If you explain my unknown, maybe it will work. Remember I know only little about Python.
Reply
#14
If you are making a webpage, the webpage is on a server. Don't you need PHP, not python?

(1) Select All - text
(2) Copy - text
(3) Paste - text

A user enters text, you save it and then display it.

Your text is then the php variable $data, do what you like with it!

For example, display it in another webpage: output.html.php

Quote:<?php

if(isset($_POST['textdata']))
{
$data=$_POST['textdata'];
$fp = fopen('data.txt', 'a');
fwrite($fp, $data);
fclose($fp);
echo file_get_contents("data.txt");
?><br>
<?php
}
?>

Maybe this old stackoverflow link will help
Reply
#15
Thanks @Pedroski55. Im using CodeIgniter which is a PHP framework. I have built the facility for users to create their adverts & I know how to attach the adverts into ONE category but CodeIgniter wont allow more than one category. Im trying copy the link to the advert then paste it into various categories. A simple wish but so difficult to achieve.
Reply
#16
Try phphelp.com then, I have got some good advice there in the past.

State your problem very clearly though!

Maybe javascript can do that easily. This script switches a link on in my homework page at a specified time, you could easily change it to do your job I think.

Given a link of my page like this:

Quote:<li id="link"><a href='#'>学期第17周<p>请等到第17周周1</p></a></li>

The javascript will put the link in there at the specified time. I don't think you need Python at all!

Quote:<script>
var linkMsg = document.getElementById("link");
var kickoff = new Date("February 26, 2019 06:00:00");
//

function checkForValidation() {
var currentDate = new Date();
//
if (currentDate > kickoff) {
linkMsg.innerHTML = "<a href='17week7.html'>学期第七周 week7</a>";
}
}
//
window.onload = checkForValidation();
</script>

Try a javascript forum to solve your problem!
Reply
#17
I will try phphelp.com & I would like to try Javascript also. Do yu have a link for Javascript Forum?
Reply
#18
Sorry, no good link for javascript, I really only use what I need, I am not good at this stuff.

I'm told javascript is easy to manipulate, so if security is an issue for you, don't use it, use PHP!

I just run a little homework page, no credit cards or personal info!
Reply
#19
In python, to copy the contents of one file to another without using the clipboard
filename = 'thisfile.txt'
with open(filename) as inputfile:
    blob = inputfile.read()
output_filename = 'thatfile.txt'
with open(output_filename,'w') as outfile:
    outfile.write(blob)
Reply
#20
(Jul-21-2021, 03:04 PM)jefsummers Wrote: In python, to copy the contents of one file to another without using the clipboard
filename = 'thisfile.txt'
with open(filename) as inputfile:
    blob = inputfile.read()
output_filename = 'thatfile.txt'
with open(output_filename,'w') as outfile:
    outfile.write(blob)

Thanks @jefsummers - Copying from one file will be OK but to overwrite the entire contents into another file would not work. We need to go to bottom then append to the 2nd file. Is that feasible?

CodeIgniter does facilitate "Open, bottom & Append".

Would changing the 'w' with 'a' work? - with open(output_filename,'a') as outfile:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Help with my coding happy_nutella 1 718 Oct-08-2024, 06:52 PM
Last Post: jefsummers
  Split Bytearray into separate Files by Hex delimter lastyle 5 6,684 Mar-09-2023, 07:49 AM
Last Post: bowlofred
  Python Split json into separate json based on node value CzarR 1 9,905 Jul-08-2022, 07:55 PM
Last Post: Larz60+
  importing functions from a separate python file in a separate directory Scordomaniac 3 2,326 May-17-2022, 07:49 AM
Last Post: Pedroski55
  wait for the first of these events Skaperen 4 3,460 Mar-07-2022, 08:46 PM
Last Post: Gribouillis
  [split] Very basic coding issue aary 4 3,488 Jun-03-2020, 11:59 AM
Last Post: buran
  Simulating events using Hawkes akshit2291 1 2,828 Sep-25-2018, 04:17 AM
Last Post: Larz60+
  win32com Events not catching dageci 0 4,565 Aug-06-2018, 03:18 PM
Last Post: dageci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020