Snippets Collections
/******************************************************************************

Write a program that would accept a stream of characters as input and  display only the letters removing the spaces. Convert all vowels to uppercase and  all consonants to lowercase.

     Sample Output:   

Enter a stream of characters:       Hello    World    123!!!

                                 hEllOwOrld

*******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <string.h>

char Determine_Cons_Vow (char *S);
char Remove_Space_Number (char *S);
char String[100], No_Space_Number[100], Cons_Vow_String[100];
int main()
{
    printf("Input a string of characters: ");
    scanf("%[^\n]%*c", String);
    
    printf ("Before:                     %s\n", String);
    
    Remove_Space_Number(String);
    
    printf ("Without Spaces and Numbers: %s\n", No_Space_Number);
    
    Determine_Cons_Vow(No_Space_Number);
    
    printf ("Final:                      %s", Cons_Vow_String);
    
    return 0;
}

char Remove_Space_Number(char *S)
{
    
    int j=0;
    for (int i=0; i<=100; i++)
    {
        if (String[i] != ' ')
        {
            if (isalpha(String[i]))
            {
                No_Space_Number[j]=String[i];
                j++;
            }
        }
    }
    for (int i=0; i<=100; i++)
    {
        return No_Space_Number[i];
    }
}

char Determine_Cons_Vow (char *S)
{
    int j=0;
    
    for (int i=0; i<=100; i++) 
    {
        Cons_Vow_String[i]=No_Space_Number[i];
    }
    
    for (int i=0; i<=100; i++)
    {
        if (Cons_Vow_String[i] == 'a' || Cons_Vow_String[i] == 'e' || Cons_Vow_String[i] == 'i' ||Cons_Vow_String[i] == 'o' || Cons_Vow_String[i] == 'u' || Cons_Vow_String[i] == 'A' || Cons_Vow_String[i] == 'E' || Cons_Vow_String[i] == 'I' || Cons_Vow_String[i] == 'O' || Cons_Vow_String[i] == 'U') 
        {
            Cons_Vow_String[i] = toupper(Cons_Vow_String[i]);
        }
        else
        Cons_Vow_String[i] = tolower(Cons_Vow_String[i]);
    }
    
    for (int i=0; i<=100; i++)
    {
        return Cons_Vow_String[i];
    }
}
import mysql.connector
import json
import os

# Connect to MySQL
conn = mysql.connector.connect(
    host="localhost",
    user="root",
    password="Eimaipolykala1",
    database="twitter_db"
)
cursor = conn.cursor()

# Path to the directory containing JSON files
json_dir = r'C:\Users\User\Desktop\DBL Data Challenge\data'


# Loop through JSON files in the directory
for filename in os.listdir(json_dir):
    data_agg = []
    if filename.endswith('.json'):
        with open(os.path.join(json_dir, filename), 'r') as file:
            for line in file:
                try :
                # Load each line as JSON

                    data = json.loads(line)
                    data_agg.append(data)
                except JSONDecodeError as e:
                    print(f"Error in {filename}: {e}")
            
            
        for item in data_agg:
            # Insert data into MySQL table
            query = "INSERT INTO raw_data_proto (data, filename) VALUES (%s, %s)"
            values = (json.dumps(item), filename)
            cursor.execute(query, values)

# Commit changes and close connections
conn.commit()
cursor.close()
conn.close()
import mysql.connector
import json
import os

# Connect to MySQL
conn = mysql.connector.connect(
    host="localhost",
    user="root",
    password="Eimaipolykala1",
    database="twitter_db"
)
cursor = conn.cursor()

# Path to the directory containing JSON files
json_dir = r'C:\Users\User\Desktop\DBL Data Challenge\data'


# Loop through JSON files in the directory
for filename in os.listdir(json_dir):
    data_agg = []
    if filename.endswith('.json'):
        with open(os.path.join(json_dir, filename), 'r') as file:
            for line in file:
                # Load each line as JSON

                data = json.loads(line)
                data_agg.append(data)
            
            
        for item in data_agg:
            # Insert data into MySQL table
            query = "INSERT INTO raw_data_proto (data, filename) VALUES (%s, %s)"
            values = (json.dumps(item), filename)
            cursor.execute(query, values)

# Commit changes and close connections
conn.commit()
cursor.close()
conn.close()
Run df -h to verify your root partition is full (100%)
Run lsblk and then lsblk -f to get block device details
sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp
sudo growpart /dev/DEVICE_ID PARTITION_NUMBER
lsblk to verify partition has expanded
sudo resize2fs /dev/DEVICE_IDPARTITION_NUMBER
Run df -h to verify your resized disk
sudo umount /tmp
#include <stdio.h>
#include <string.h>

int sum_of_substrings(char *num) {
    int sum = 0;
    int len = strlen(num);
    for (int i = 0; i < len; i++) {
        int val = 0;
        for (int j = i; j < len; j++) {
            val = val * 10 + (num[j] - '0');
            sum += val;
        }
    }
    return sum;
}

int main() {
    char num[] = "1234";
    printf("Sum of all substrings of '%s': %d\n", num, sum_of_substrings(num));
    return 0;
}
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void print_square_of_numbers(char *string) {
    char *endptr;
    while (*string != '\0') {
        if (isdigit(*string)) {
            long num = strtol(string, &endptr, 10);
            printf("%ld ", num * num);
            string = endptr;
        } else {
            string++;
        }
    }
    printf("\n");
}

int main() {
    char input_string[] = "wha4ts12ap1p";
    printf("Square of numbers in '%s': ", input_string);
    print_square_of_numbers(input_string);
    return 0;
}
#include <stdio.h>
#include <string.h>

void reverse_string_recursive(char *str) {
    if (*str == '\0') {
        return;
    }
    reverse_string_recursive(str + 1);
    printf("%c", *str);
}

int main() {
    char input_string[] = "hello world";
    printf("Original string: %s\n", input_string);
    printf("Reversed string: ");
    reverse_string_recursive(input_string);
    printf("\n");
    return 0;
}
#include <stdio.h>

int first_occurrence(char *string, char ch) {
    int position = -1;
    int index = 0;
    while (string[index] != '\0') {
        if (string[index] == ch) {
            position = index;
            break;
        }
        index++;
    }
    return position;
}

int main() {
    char input_string[] = "hello world";
    char character_to_find = 'o';
    printf("First occurrence of '%c' in '%s': %d\n", character_to_find, input_string, first_occurrence(input_string, character_to_find));
    return 0;
}
#include <stdio.h>
#include <string.h>

void delete_chars(char *string1, char *string2) {
    int len1 = strlen(string1);
    int len2 = strlen(string2);
    int map[256] = {0};
    for (int i = 0; i < len2; i++) {
        map[string2[i]] = 1;
    }
    int index = 0;
    for (int i = 0; i < len1; i++) {
        if (map[string1[i]] == 0) {
            string1[index++] = string1[i];
        }
    }
    string1[index] = '\0';
}

int main() {
    char string1[] = "whatsapp";
    char string2[] = "wat";
    printf("String1: %s\n", string1);
    printf("String2: %s\n", string2);
    delete_chars(string1, string2);
    printf("After deleting characters from string2 in string1: %s\n", string1);
    return 0;
}
#include <stdio.h>

int count_character(char *string, char ch) {
    int count = 0;
    while (*string != '\0') {
        if (*string == ch) {
            count++;
        }
        string++;
    }
    return count;
}

int main() {
    char input_string[] = "hello world";
    char character_to_count = 'o';
    printf("Count of '%c' in '%s': %d\n", character_to_count, input_string, count_character(input_string, character_to_count));
    return 0;
}
#include <stdio.h>

void cartesian_product(char *str1, char *str2) {
    while (*str1 != '\0') {
        char *temp = str2;
        while (*temp != '\0') {
            printf("%c%c ", *str1, *temp);
            temp++;
        }
        str1++;
    }
    printf("\n");
}

int main() {
    char string1[] = "abc";
    char string2[] = "ab";
    printf("Cartesian product of '%s' and '%s': ", string1, string2);
    cartesian_product(string1, string2);
    return 0;
}
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h> 

int main() {
    const char *filename = "example.txt";
    mode_t mode = 0644; 
    
    if (chmod(filename, mode) == -1) {
        perror("chmod");
        exit(EXIT_FAILURE);
    }
    
    printf("File permission successfully changed\n");
    return 0;
}
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdlib.h>

int main() {
    char dname[100]; 
    DIR *p;
    struct dirent *d;

    printf("Enter directory name: ");
    scanf("%s", dname);

    p = opendir(dname);
    if (p == NULL) {
        perror("Cannot open directory");
        exit(EXIT_FAILURE);
    }

    while ((d = readdir(p)) != NULL) {
        printf("%s\n", d->d_name);
    }

    closedir(p); 
    return 0;
}
//  $errorLine = '';
                        //     for ($i = $startLine; $i <= $endLine; $i++) {
                        //         $errorLine .= $lines[$i - 1];
                        //     }
+++++++++++++++++++++++++++++++++++++++++++++++++
$date = Carbon::now()->format('F j, Y, g:i:s A e');
//     "date": "May 7, 2024, 11:22:04 AM UTC",
+++++++++++++++++++++++++++++++++++++++++++++++++
<div class="related-post">
  <div class="container">
    <h2 id="recent">Related Articles</h2>
    <div class="row">
      <?php
      $current_post_type = get_post_type($post);
      // The query arguments
      $args = array(
        'posts_per_page' => 3,
        'order' => 'rand',
        'orderby' => 'ID',
        'post_type' => 'post',
        'post_status' => 'publish',
        'numberposts' => -1,
        'post__not_in' => array($post->ID)
      );

      // Create the related query
      $rel_query = new WP_Query($args);

      // Check if there is any related posts
      if ($rel_query->have_posts()):
        ?>


        <?php
        // The Loop
        while ($rel_query->have_posts()):
          $rel_query->the_post();
          $post_tags = get_the_tags();
          ?>
          <div class="col-md-4 col-sm-6 col-12 related-col">

            <?php the_post_thumbnail(); ?>
            <div class="taxonomy-post_tag wp-block-post-terms">
              <?php
              if ($post_tags) {
                if (count($post_tags) > 0) {
                  foreach ($post_tags as $key => $val) {
                    ?>
                    <a href="<?php echo get_permalink(); ?>">
                      <?php echo $val->name; ?>
                    </a>
                    <?php
                  }
                }
              }
              ?>
            </div>
            <div class="wp-block-post-date"> <time>
                <?php echo get_the_date() ?>
              </time></div>
            <a href="<?php the_permalink() ?>">
              <h3 class="entry-title">
                <?php the_title() ?>
              </h3>
            </a>

          </div>
          <?php
        endwhile;
        ?>

        <?php
      endif;

      // Reset the query
      wp_reset_query();

      ?>
    </div>
  </div>
</div>
n = int(input('Total number of items in list: '))
L = []

# Input items into the list
for i in range(n):
    item = int(input('Enter the item: '))
    L.append(item)

# Selection sort algorithm
for i in range(n - 1):
    min_index = i

    for j in range(i + 1, n):
        if L[j] < L[min_index]:
            min_index = j

    L[i], L[min_index] = L[min_index], L[i]

# Print the sorted list
print('Sorted list:\n', L)
n=int(input('total number of items in list'))
L=[]
for i in range(n):
    item=int(input('enter the item'))
    L.append(item)
n=int(input('total number of items in list'))
L=[]
for i in range(n):
    item=int(input('enter the item'))
    L.append(item)



for i in range(1,n):
    k=L[i]
    j=i-1
    while j>=0 and k<L[j]:
        L[j+1]=L[j]
        j=j-1
    else:
        L[j+1]=k
print('sorted list:\n',L)

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-aiplatform
import vertexai

from vertexai.generative_models import GenerativeModel, Part

# TODO(developer): Update and un-comment below line
# project_id = "PROJECT_ID"

vertexai.init(project=project_id, location="us-central1")

model = GenerativeModel(model_name="gemini-1.0-pro-vision-001")

response = model.generate_content(
    [
        Part.from_uri(
            "gs://cloud-samples-data/generative-ai/image/scones.jpg",
            mime_type="image/jpeg",
        ),
        "What is shown in this image?",
    ]
)

print(response.text)
   var fields = g_form.getEditableFields();

    for (var x = 0; x < fields.length; x++) {
        if (fields[x] === 'start_date' || fields[x] == 'end_date') {
            // alert("x: " + fields[x]);
            if (get_start_date == '' || get_end_date == '') {
                g_form.addErrorMessage("Date de début planifiée et/ou Date de fin planifiée  doit être remplies !");
                return false;
            }
        }
    }
//SJF                                                                                                                                                 #include<stdio.h>
#define size 20
int main(void)
{
      int i , j, n , t, p[size],bt[size],wt[size],tat[size];
      float awt=0,atat=0;
      printf("Enter the number of processes:");
      scanf(" %d",&n);
      printf("Enter the process numbers:");
      for(i=0;i<n;i++)
      {
            scanf(" %d",&p[i]);
      }
      printf("Enter burst time of the processes:");
      for(i=0;i<n;i++)
      {
            scanf(" %d",&bt[i]);
      }
      //Applying bubble sort
      for(i=1;i<n;i++)
      {
            for(j=0;j<n-i;j++)
            {
                  t=bt[j];
                  bt[j]=bt[j+1];
                  bt[j+1]=t;
                  t=p[j];
                  p[j]=p[j+1];
                  p[j+1]=t;
            }
      }
      printf("Process\tBT\tWt\tTAT\n");
      for(i=0;i<n;i++)
      {
            wt[i]=0;
            tat[i]=0;
            for(j=0;j<i;j++)
            {
                  wt[i]=wt[i]+bt[j];
            }
            tat[i]=wt[i]+bt[i];
            awt=awt+wt[i];
            atat=atat+tat[i];
            printf("%d\t%d\t%d\t%d\n",p[i],bt[i],wt[i],tat[i]);
      }
      printf("Average waiting time:%0.2f\n",awt/n);
      printf("Average turn around time:%0.2f\n",atat/n);
      return 0;
}

//Our SJF                                                                                                                                       #include<stdio.h>
int main()
{
                              int at[10],bt[10],p[10];
            int n,i,j,temp,time=0,count,over=0,sum_wait=0,sum_turnaround=0,start;
            float avgwait,avgturn;
            printf("Enter the number of processes\n");
            scanf("%d",&n);
            for(i=0;i<n;i++)
            {
                                    printf("Enter the arrival time and execution time for process %d\n",i+1);
                scanf("%d%d",&at[i],&bt[i]);
                p[i]=i+1;
            }
            for(i=0;i<n-1;i++)
            {
                for(j=i+1;j<n;j++)
                {
                   if(at[i]>at[j])
                   {
                    temp=at[i];
                    at[i]=at[j];
                    at[j]=temp;
                    temp=bt[i];
                    bt[i]=bt[j];
                    bt[j]=temp;
                    temp=p[i];
                    p[i]=p[j];
                    p[j]=temp;     
                   }
                        
                 }
            }
            printf("\nProcess\tAT\tBT\tWT\tTAT\n");
            while(over<n)
            {
               count=0;
               for(i=over;i<n;i++)
               {
                  if(at[i]<=time)
                     count++;
                  else
                     break;
               }
               if(count>1)
               {
                 for(i=over;i<over+count-1;i++)
                 {
                    for(j=i+1;j<over+count;j++)
                    {
                      if(bt[i]>bt[j])
                      {
                        temp=at[i];
                        at[i]=at[j];
                        at[j]=temp;
                        temp=bt[i];
                        bt[i]=bt[j];
                        bt[j]=temp;
                        temp=p[i];
                        p[i]=p[j];
                        p[j]=temp;     
                       }
                     }                     
                   }
                 }
                start=time;
                time+=bt[over];
                printf("p[%d]\t%d\t%d\t%d\t%d\n",p[over],at[over],bt[over],time-at[over]-bt[over],time-at[over]);
                sum_wait+=time-at[over]-bt[over];
                                                                                                sum_turnaround+=time-at[over];
                over++;
            }
            avgwait=(float)sum_wait/(float)n;
            avgturn=(float)sum_turnaround/(float)n;
            printf("Average waiting time is %f\n",avgwait);
            printf("Average turnaround time is %f\n",avgturn);
            return 0;
}  
//FCFS                                                                                                         #include<stdio.h>
int main(void)
{
      int n,at[10],bt[10],ct[10],tat[10],wt[10],sum,i,j,k;
      float totaltat=0,totalwt=0;
      printf("Enter No of processors:");
      scanf(" %d",&n);
      for(i=0;i<n;i++)
      {
            printf("Enter the arrival time of processor %d:",i+1);
            scanf(" %d",&at[i]);
      }
      for(i=0;i<n;i++)
      {
            printf("Enter the burst time of processor %d:",i+1);
            scanf(" %d",&bt[i]);
      }
      //Calculation of completion times for each processor
      sum=at[0];
      for(j=0;j<n;j++)
      {
            sum=sum+bt[j];
            ct[j]=sum;
      }
      //Calculation of turn around time
      for(k=0;k<n;k++)
      {
            tat[k]=ct[k]-at[k];
            totaltat=totaltat+tat[k];
      }
      //Calculation of waiting time
      for(i=0;i<n;i++)
      {
            wt[i]=tat[i]-bt[i];
            totalwt=totalwt+wt[i];
      }
      printf("Process\tAT\tBT\tCT\tTAT\tWt\n");
      for(i=0;i<n;i++)
      {
            printf("\nP%d\t%d\t%d\t%d\t%d\t%d\t\n",i+1,at[i],bt[i],ct[i],tat[i],wt[i]);
      }
      printf("average of turn around time:%0.1f\n",totaltat/n);
      printf("average of waiting time:%0.1f\n",totalwt/n);
      return 0;
}
//Optimal page replacement
#include<stdio.h>
int n;
int main()
{
int seq[30],fr[5],pos[5],find,flag,max,i,j,m,k,t,s;
int count=1,pf=0,p=0;
float pfr;
printf("Enter maximum limit of the sequence: ");
scanf("%d",&max);
printf("\nEnter the sequence: ");
 for(i=0;i<max;i++)
scanf("%d",&seq[i]);
 printf("\nEnter no. of frames: ");
 scanf("%d",&n);
fr[0]=seq[0];
pf++;
printf("%d\t",fr[0]);
i=1;
while(count<n)
{
flag=1; p++;
for(j=0;j<i;j++)
{
if(seq[i]==seq[j]) flag=0;
}
if(flag!=0)
{
 fr[count]=seq[i];
 printf("%d\t",fr[count]);
 count++;
pf++;

}
i++;
}
 
printf("\n");
for(i=p;i<max;i++)
{
flag=1;
for(j=0;j<n;j++)
{
if(seq[i]==fr[j])
flag=0;
}
if(flag!=0)

{
for(j=0;j<n;j++)
{
m=fr[j];
for(k=i;k<max;k++)
{
if(seq[k]==m)
{
    pos[j]=k;
     break;

 }
else
pos[j]=1;

}
}
for(k=0;k<n;k++)
{
if(pos[k]==1)
flag=0;
}
if(flag!=0)
s=findmax(pos);
 if(flag==0)
{
for(k=0;k<n;k++)
{
if(pos[k]==1)
{
s=k;
 break;
}
}
}
fr[s]=seq[i];
for(k=0;k<n;k++)
printf("%d\t",fr[k]);
pf++;
printf("\n");
}
}
pfr=(float)pf/(float)max;
printf("\nThe no. of page faults are %d",pf);
printf("\nPage fault rate %f",pfr);
getch();
}
int findmax(int a[])
{
int max,i,k=0;
max=a[0];
for(i=0;i<n;i++)
{
if(max<a[i])
{
  max=a[i];
   k=i;
}
}
return k;
}
//FIFO PAGE REPLACEMENT ALGORITHM
#include<stdio.h>
#include<conio.h>
int main()
{
int i, j, k, f, pf=0, count=0, rs[25], m[10], n;
printf("\n Enter the length of reference string -- ");
scanf("%d",&n);
printf("\n Enter the reference string -- ");
 for(i=0;i<n;i++)
scanf("%d",&rs[i]);
 printf("\n Enter no. of frames -- ");
 scanf("%d",&f);
for(i=0;i<f;i++)
m[i]=-1;

printf("\n The Page Replacement Process is -- \n");
 for(i=0;i<n;i++)
{
for(k=0;k<f;k++)
{
  if(m[k]==rs[i])
  break;

}
if(k==f)
{
m[count++]=rs[i];
pf++;

}

for(j=0;j<f;j++)
printf("\t%d",m[j]);
if(k==f)
printf("\tPF No. %d",pf);
printf("\n");
if(count==f)
count=0;
}
printf("\n The number of Page Faults using FIFO are %d",pf);
getch();

}
CREATE TABLE stats_table (
    id INT AUTO_INCREMENT PRIMARY KEY
);
SELECT user_mention0_name, user_mention0_id, COUNT(*) AS num_rows 
FROM tweets_extend 
WHERE user_mention0_id IN (56377143, 106062176, 18332190, 22536055, 124476322, 26223583, 2182373406, 38676903, 1542862735, 253340062, 218730857, 45621423, 20626359) 
GROUP BY user_mention0_name, user_mention0_id
ORDER BY num_rows DESC;

ALTER TABLE stats_table ADD COLUMN num_rows1 INT;
INSERT INTO stats_table (user_mention1name, user_mention1id, num_rows1)
SELECT COUNT(*) AS num_rows1
FROM tweets_extend 
WHERE user_mention1_id IN (56377143, 106062176, 18332190, 22536055, 124476322, 26223583, 2182373406, 38676903, 1542862735, 253340062, 218730857, 45621423, 20626359)
GROUP BY user_mention1_name, user_mention1_id
ORDER BY num_rows1 DESC

CREATE TABLE stats_table (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_mention0_name VARCHAR(255),
    user_mention0_id INT,
    user_mention1_name VARCHAR(255),
    user_mention1_id INT,
    num_rows0 INT,
    num_rows1 INT
);

INSERT INTO stats_table (user_mention0_name, user_mention0_id, num_rows0)
SELECT user_mention0_name, user_mention0_id, COUNT(*) AS num_rows
FROM tweets_extend 
WHERE user_mention0_id IN (56377143, 106062176, 18332190, 22536055, 124476322, 26223583, 2182373406, 38676903, 1542862735, 253340062, 218730857, 45621423, 20626359) 
GROUP BY user_mention0_name, user_mention0_id
ORDER BY num_rows DESC;

INSERT INTO stats_table (user_mention1_name, user_mention1_id, num_rows1)
SELECT user_mention1_name, user_mention1_id, COUNT(*) AS num_rows1
FROM tweets_extend 
WHERE user_mention1_id IN (56377143, 106062176, 18332190, 22536055, 124476322, 26223583, 2182373406, 38676903, 1542862735, 253340062, 218730857, 45621423, 20626359)
GROUP BY user_mention1_name, user_mention1_id
ORDER BY num_rows1 DESC;

SELECT num_rows0, num_rows1
FROM stats_table
WHERE user_mention0_id = 56377143 OR user_mention1_id = 56377143; -- FOR EXAMPLE TO SEE KLM HOW MANY --TWEEETS IT HAS BEEN MENTIONED

ALTER TABLE stats_table ADD COLUMN avg_char0 FLOAT;
ALTER TABLE stats_table ADD COLUMN avg_char1 FLOAT;
INSERT INTO stats_table (avg_char0, avg_char1)
SELECT 
    CASE WHEN user_mention1_id IS NULL THEN user_mention0_id ELSE user_mention1_id END AS user_mention_id,
    AVG(CHAR_LENGTH(full_text)) AS average_characters
FROM tweets_extend  
GROUP BY user_mention0_id, user_mention1_id;
Sub LoopEachOpenWorkbook()

'PURPOSE: Add today's date into every currently open Excel workbook
'SOURCE: www.TheSpreadsheetGuru.com

Dim wb As Workbook

For Each wb In Application.Workbooks
  If wb.Name <> "PERSONAL.xlsb" Then
    
    'Add today's date to cell A1 of first worksheet in workbook
      wb.Worksheets(1).Range("A1") = Date
  
  End If
Next wb

End Sub
Option Explicit
                      'Remember to add a reference to Microsoft Visual Basic for Applications Extensibility 
                      'Exports all VBA project components containing code to a folder in the same directory as this spreadsheet.
                      Public Sub ExportAllComponents()
                          Dim VBComp As VBIDE.VBComponent
                          Dim destDir As String, fName As String, ext As String 
                          'Create the directory where code will be created.
                          'Alternatively, you could change this so that the user is prompted
                          If ActiveWorkbook.Path = "" Then
                              MsgBox "You must first save this workbook somewhere so that it has a path.", , "Error"
                              Exit Sub
                          End If
                          destDir = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name & " Modules"
                          If Dir(destDir, vbDirectory) = vbNullString Then MkDir destDir
                          
                          'Export all non-blank components to the directory
                          For Each VBComp In ActiveWorkbook.VBProject.VBComponents
                              If VBComp.CodeModule.CountOfLines > 0 Then
                                  'Determine the standard extention of the exported file.
                                  'These can be anything, but for re-importing, should be the following:
                                  Select Case VBComp.Type
                                      Case vbext_ct_ClassModule: ext = ".cls"
                                      Case vbext_ct_Document: ext = ".cls"
                                      Case vbext_ct_StdModule: ext = ".bas"
                                      Case vbext_ct_MSForm: ext = ".frm"
                                      Case Else: ext = vbNullString
                                  End Select
                                  If ext <> vbNullString Then
                                      fName = destDir & "\" & VBComp.Name & ext
                                      'Overwrite the existing file
                                      'Alternatively, you can prompt the user before killing the file.
                                      If Dir(fName, vbNormal) <> vbNullString Then Kill (fName)
                                      VBComp.Export (fName)
                                  End If
                              End If
                          Next VBComp
                      End Sub
                      
' Req'd Refs: Late Binding  -> None required
'             Early Binding -> Microsoft Scripting Runtime
#Const FSO_EarlyBind = True
#If FSO_EarlyBind = True Then
    Private pFSO                As Scripting.FileSystemObject
#Else
    Private pFSO                As Object
#End If


#If FSO_EarlyBind = True Then
Public Function oFSO() As Scripting.FileSystemObject
#Else
Public Function oFSO() As Object
#End If
    If pFSO Is Nothing Then
        #If FSO_EarlyBind = True Then
            Set pFSO = New FileSystemObject
        #Else
            Set pFSO = CreateObject("Scripting.FileSystemObject")
        #End If
    End If
    Set oFSO = pFSO
End Function

Public Sub oFSO_Clear()
    'Be sure to always run this when closing your Form/DB to avoid
    '   hidden instances from running in the background!
    Set pFSO = Nothing
End Sub
Sub SendOutlookMessages()'Dimension variables.
    Dim OL As Object, MailSendItem As Object
    Dim W As Object
    Dim MsgTxt As String, SendFile As String
    Dim ToRangeCounter As Variant
    
    'Identifies Word file to send
    SendFile = Application.GetOpenFilename(Title:="Select MS Word " & _
    "file to mail, then click 'Open'", buttontext:="Send", _
    MultiSelect:=False)'Starts Word session
    Set W = GetObject(SendFile)'Pulls text from file for message body
    MsgTxt = W.Range(Start:=W.Paragraphs(1).Range.Start, _
    End:=W.Paragraphs(W.Paragraphs.Count).Range.End)'Ends Word session
    Set W = Nothing
    
    'Starts Outlook session
    Set OL = CreateObject("Outlook.Application")
    Set MailSendItem = OL.CreateItem(olMailItem)
    
    ToRangeCounter = 0
    
    'Identifies number of recipients for To list.
    For Each xCell In ActiveSheet.Range(Range("tolist"), _
    Range("tolist").End(xlToRight))
    ToRangeCounter = ToRangeCounter + 1
    Next xCell
    
    If ToRangeCounter = 256 Then ToRangeCounter = 1
    
    'Creates message
    With MailSendItem
    .Subject = ActiveSheet.Range("subjectcell").Text
    .Body = MsgTxt
    
    'Creates "To" list
    For Each xRecipient In Range("tolist").Resize(1, ToRangeCounter)
    RecipientList = RecipientList & ";" & xRecipient
    Next xRecipient
    
    .To = RecipientList
    .Send
    End With
    
    'Ends Outlook session
    Set OL = Nothing
    
End Sub
Sub SendOutlookMessages()'Dimension variables.
    Dim OL As Object, MailSendItem As Object
    Dim W As Object
    Dim MsgTxt As String, SendFile As String
    Dim ToRangeCounter As Variant
    
    'Identifies Word file to send
    SendFile = Application.GetOpenFilename(Title:="Select MS Word " & _
    "file to mail, then click 'Open'", buttontext:="Send", _
    MultiSelect:=False)'Starts Word session
    Set W = GetObject(SendFile)'Pulls text from file for message body
    MsgTxt = W.Range(Start:=W.Paragraphs(1).Range.Start, _
    End:=W.Paragraphs(W.Paragraphs.Count).Range.End)'Ends Word session
    Set W = Nothing
    
    'Starts Outlook session
    Set OL = CreateObject("Outlook.Application")
    Set MailSendItem = OL.CreateItem(olMailItem)
    
    ToRangeCounter = 0
    
    'Identifies number of recipients for To list.
    For Each xCell In ActiveSheet.Range(Range("tolist"), _
    Range("tolist").End(xlToRight))
    ToRangeCounter = ToRangeCounter + 1
    Next xCell
    
    If ToRangeCounter = 256 Then ToRangeCounter = 1
    
    'Creates message
    With MailSendItem
    .Subject = ActiveSheet.Range("subjectcell").Text
    .Body = MsgTxt
    
    'Creates "To" list
    For Each xRecipient In Range("tolist").Resize(1, ToRangeCounter)
    RecipientList = RecipientList & ";" & xRecipient
    Next xRecipient
    
    .To = RecipientList
    .Send
    End With
    
    'Ends Outlook session
    Set OL = Nothing
    
End Sub
' Variable declarations
Dim blNotFirstIteration As Boolean
Dim Fil As File
Dim hFolder As Folder, SubFolder As Folder
Dim FileExt As String
Dim FSO As Scripting.FileSystemObject

' Recursive procedure for iterating through all files in all subfolders
' of a folder and locating specific file types by file extension.
Sub FindFilesInFolders(ByVal HostFolder As String, FileTypes As Variant)
'(1) This routine uses Early Binding so you must add reference to Microsoft Scripting Runtime:
' Tools > References > Microsoft Scripting Runtime
'(2) Call procedure using a command like:
' Call FindFilesInFolders("C:\Users\MHS\Documents", Array("xlsm", "xlsb"))
    If FSO Is Nothing Then Set FSO = New Scripting.FileSystemObject
    Set hFolder = FSO.GetFolder(HostFolder)

    ' iterate through all files in the root of the main folder
    If Not blNotFirstIteration Then
      For Each Fil In hFolder.Files
          FileExt = FSO.GetExtensionName(Fil.Path)
    
          ' check if current file matches one of the specified file types
          If Not IsError(Application.Match(FileExt, FileTypes, 0)) Then
              ' ****************************************
              ' Insert your code here
              ' ****************************************
              Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1) = Fil.Path
          End If
      Next Fil
    
      ' make recursive call, if main folder contains subfolder
      If Not hFolder.SubFolders Is Nothing Then
          blNotFirstIteration = True
          Call FindFilesInFolders(HostFolder, FileTypes)
      End If
    
    ' iterate through all files in all the subfolders of the main folder
    Else
      For Each SubFolder In hFolder.SubFolders
          For Each Fil In SubFolder.Files
              FileExt = FSO.GetExtensionName(Fil.Path)
    
              ' check if current file matches one of the specified file types
              If Not IsError(Application.Match(FileExt, FileTypes, 0)) Then
                  ' ****************************************
                  ' Insert your code here
                  ' ****************************************
                  Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1) = Fil.Path
              End If
          Next Fil
    
          ' make recursive call, if subfolder contains subfolders
          If Not SubFolder.SubFolders Is Nothing Then _
              Call FindFilesInFolders(HostFolder & "\" & SubFolder.Name, FileTypes)
    
      Next SubFolder
    End If
    blNotFirstIteration = False
End Sub
Sub AllEnvironVariables()
    Dim strEnviron As String
    Dim VarSplit As Variant
    Dim i As Long
    For i = 1 To 255
        strEnviron = Environ$(i)
        If LenB(strEnviron) = 0& Then GoTo TryNext:
        VarSplit = Split(strEnviron, "=")
        If UBound(VarSplit) > 1 Then Stop
        Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Value = i
        Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1).Value = VarSplit(0)
        Range("C" & Range("C" & Rows.Count).End(xlUp).Row + 1).Value = VarSplit(1)
TryNext:
    Next
End Sub
Sub GetWordData()
'Note: this code requires a reference to the Word object model. See under the VBE's Tools|References.
Application.ScreenUpdating = False
Dim wdApp As New Word.Application, wdDoc As Word.Document, c As Long, r As Long
Dim strFolder As String, strFile As String, WkBk As Workbook, WkSht As Worksheet
strFolder = GetFolder: If strFolder = "" Then GoTo ErrExit
Set WkBk = ActiveWorkbook
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
  Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  Set WkSht = WkBk.Sheets.Add: r = 4
  WkSht.Name = Split(strFile, ".doc")(0)
  WkBk.Sheets(1).Range.Copy
  WkSht.Paste
  WkSht.Range("A2").Value = WkSht.Name
  With wdDoc
    With .Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        'Find blocks of text of interest
        .Text = "Uid:*Units:*^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Execute
      End With
      Do While .Find.Found
        r = r + 1
        'Parse & write the text to Excel
        For c = 1 To 4
          WkSht.Cells(r, c).Value = Trim(Split(Split(.Text, vbCr)(c - 1), ":")(1))
        Next
        .Collapse wdCollapseEnd
        .Find.Execute
      Loop
    End With
    .Close SaveChanges:=False
  End With
  strFile = Dir()
Wend
ErrExit:
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing: Set WkBk = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
End Function
Sub GetWordData()
'Note: this code requires a reference to the Word object model. See under the VBE's Tools|References.
Application.ScreenUpdating = False
Dim wdApp As New Word.Application, wdDoc As Word.Document, c As Long, r As Long
Dim strFolder As String, strFile As String, WkBk As Workbook, WkSht As Worksheet
strFolder = GetFolder: If strFolder = "" Then GoTo ErrExit
Set WkBk = ActiveWorkbook
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
  Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  Set WkSht = WkBk.Sheets.Add: r = 4
  WkSht.Name = Split(strFile, ".doc")(0)
  WkBk.Sheets(1).Range.Copy
  WkSht.Paste
  WkSht.Range("A2").Value = WkSht.Name
  With wdDoc
    With .Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        'Find blocks of text of interest
        .Text = "Uid:*Units:*^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Execute
      End With
      Do While .Find.Found
        r = r + 1
        'Parse & write the text to Excel
        For c = 1 To 4
          WkSht.Cells(r, c).Value = Trim(Split(Split(.Text, vbCr)(c - 1), ":")(1))
        Next
        .Collapse wdCollapseEnd
        .Find.Execute
      Loop
    End With
    .Close SaveChanges:=False
  End With
  strFile = Dir()
Wend
ErrExit:
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing: Set WkBk = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
End Function
Sub ShowDriveList
    Dim fs, d, dc, s, n
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives
    For Each d in dc
        s = s & d.DriveLetter & " - " 
        If d.DriveType = 3 Then
            n = d.ShareName
        Else
            n = d.VolumeName
        End If
        s = s & n & vbCrLf
    Next
    MsgBox s
End Sub
Public Function NameOf(Optional ByVal This As Variant = 0, Optional ByVal Target As Range = Nothing) As Variant
' User-Defined Function (UDF) to return Target's Worksheet.Name, Workbook.Name, or Workbook.Path
' otherwise, return Application.Name and .Version, .Caption, .StatusBar, .UserName, .OrganizationName, or .ActivePrinter
' otherwise, return environment variable "COMPUTERNAME" or any environment variable named by This (ignoring alphabetic case)
' SYNTAX: NameOf([This],[Target])
' Default This is 0 (or "sheet" or "worksheet")
' This = 0 or "sheet" or "worksheet" return Target's Worksheet.Name (default)
' This = 1 or "book" or "workbook" return Target's Workbook.Name
' This = 2 or "path" or "filepath" return Target's Workbook.Path
' This = 3 or "app" or "application" return Application.Name and Application.Version
' This = 4 or "caption" or "titlebar" return Application.Caption
' This = 5 or "statusbar" return Application.StatusBar ("Default" unless set by a macro)
' This = 6 or "user" return Application.UserName
' This = 7 or "organization" return Application.OrganizationName
' This = 8 or "printer" return Application.ActivePrinter
' This = 9 or "computer" return Environ("COMPUTERNAME")
' This = "?" or "help" return text list of recognized This
' This = any string not listed above return Environ(This)
' If Target is Nothing (default), then Target is set to the cell referencing this function (error if referenced in a VBA statement)
' otherwise, Target should be a Worksheet cell's address (like $A$1 or Sheet1!A1) or VBA Range such as Range("$A$1")
' Patterned after Excel's built-in information functions CELL and INFO
' DEVELOPER: J. Woolley (for wellsr.com)
    Dim vResult As Variant
    Application.Volatile
    If Not IsNumeric(This) Then This = Trim(LCase(This))
    Select Case This
    Case 0, "sheet", "worksheet": 
		If Target Is Nothing Then Set Target = Application.ThisCell
		vResult = Target.Parent.Name
    Case 1, "book", "workbook": 
		If Target Is Nothing Then Set Target = Application.ThisCell
		vResult = Target.Parent.Parent.Name
    Case 2, "path", "filepath": 
		If Target Is Nothing Then Set Target = Application.ThisCell
		vResult = Target.Parent.Parent.Path
    Case 3, "app", "application": 
		vResult = Application.Name & " " & Application.Version
    Case 4, "caption", "titlebar": 
		vResult = Application.Caption
    Case 5, "statusbar":
        vResult = Application.StatusBar
        If Not vResult Then vResult = "Default"
    Case 6, "user": 
		vResult = Application.UserName
    Case 7, "organization": 
		vResult = Application.OrganizationName
    Case 8, "printer": 
		vResult = Application.ActivePrinter
    Case 9, "computer": 
		vResult = Environ("COMPUTERNAME")
    Case "?", "help":
        vResult = "Worksheet, Workbook, Filepath, Application, Titlebar, Statusbar, User, Organization, Printer, Computer (EnvVar)"
    Case Else:
        vResult = Environ(CStr(This))
        If vResult = "" Then vResult = CVErr(xlErrValue)      ' #VALUE! (Error 2015)
    End Select
    NameOf = vResult
End Function
Sub GetWordData()
'Note: this code requires a reference to the Word object model. See under the VBE's Tools|References.
Application.ScreenUpdating = False
Dim wdApp As New Word.Application, wdDoc As Word.Document, c As Long, r As Long
Dim strFolder As String, strFile As String, WkBk As Workbook, WkSht As Worksheet
strFolder = GetFolder: If strFolder = "" Then GoTo ErrExit
Set WkBk = ActiveWorkbook
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
  Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  Set WkSht = WkBk.Sheets.Add: r = 4
  WkSht.Name = Split(strFile, ".doc")(0)
  WkBk.Sheets(1).Range.Copy
  WkSht.Paste
  WkSht.Range("A2").Value = WkSht.Name
  With wdDoc
    With .Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        'Find blocks of text of interest
        .Text = "Uid:*Units:*^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Execute
      End With
      Do While .Find.Found
        r = r + 1
        'Parse & write the text to Excel
        For c = 1 To 4
          WkSht.Cells(r, c).Value = Trim(Split(Split(.Text, vbCr)(c - 1), ":")(1))
        Next
        .Collapse wdCollapseEnd
        .Find.Execute
      Loop
    End With
    .Close SaveChanges:=False
  End With
  strFile = Dir()
Wend
ErrExit:
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing: Set WkBk = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
End Function
  <h4 className="text-2xl font-bold my-10">{reportData.introdcution.performance_control.title}</h4>
    <p className="mb-6">{reportData.introdcution.performance_control.description}</p>
    <table className="table-auto w-full">
      <caption className="text-lg font-semibold mb-6">{reportData.introdcution.performance_control.table.caption}</caption>
      <thead>
        <tr className="bg-gray-200">
          {Object.values(reportData.introdcution.performance_control.table.column_names).map((columnName, index) => (
            <th key={index} className="px-4 py-2">{columnName}</th>
          ))}
        </tr>
      </thead>
      <tbody>
      {isEditing ? (
          reportData.introdcution.performance_control.table.data.map((rowData, rowIndex) => (
            <tr key={rowIndex} className="bg-white">
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].insurance_revenue}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].insurance_revenue`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].loss}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].losse`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].commission_cost}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].commission_cost`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].administrative_costs}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].administrative_costs`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].other_operational_costs}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].other_operational_costs`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].non_operational_costs}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].non_operational_costs`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].personnel_costs}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].personnel_costs`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].depreciation_costs}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].depreciation_costs`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].cost_ratio}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].cost_ratio`)}
                />
              </td>
              <td className="px-4 py-2">
                <input
                  type="number"
                  className="w-full p-2 rounded-lg border border-gray-300"
                  value={editedData.introdcution.performance_control.table.data[rowIndex].profit_lost}
                  onChange={(e) => handleInputChange(e, `introdcution.performance_control.table.data[${rowIndex}].profit_lost`)}
                />
              </td>
              
            </tr>
          ))
        ) : (
        reportData.introdcution.performance_control.table.data.map((rowData, rowIndex) => (
          <tr key={rowIndex} className={rowIndex % 2 === 0 ? "bg-gray-100" : "bg-white"}>
            <td className="px-4 py-2">{rowData.insurance_revenue}</td>
            <td className="px-4 py-2">{rowData.loss}</td>
            <td className="px-4 py-2">{rowData.commission_cost}</td>
            <td className="px-4 py-2">{rowData.administrative_costs}</td>
            <td className="px-4 py-2">{rowData.other_operational_costs}</td>
            <td className="px-4 py-2">{rowData.non_operational_costs}</td>
            <td className="px-4 py-2">{rowData.personnel_costs}</td>
            <td className="px-4 py-2">{rowData.depreciation_costs}</td>
            <td className="px-4 py-2">{rowData.cost_ratio}</td>
            <td className="px-4 py-2">{rowData.profit_lost}</td>
            </tr>
          ))
        )}
        
      </tbody>
    </table>
Pro Zeile einen Dateiname
MD Ordnername1
Keine Leerzeichen im Ordnername
In TXT Datei speichern als textdatei.bat
Datei dopelklicken in dem Ordner in dem die neuen ordner gebraucht werden. 
Ordner werden erstellt
field("Parent No."; Rec."Parent No.")
{
    ApplicationArea = All;

    trigger OnDrillDown()
    var
        ChildTablePage: Page ChildTablePage;
        ChildTableRecord: Record ChildTable;
    begin
        ChildTableRecord.SetRange(ChildTableRecord."Parent No.", Rec."Parent No.");
        ChildTablePage.SetTableView(ChildTableRecord);
        ChildTablePage.Run();
    end;
}
const model = this.data.model,
    records = this.data.selectedRecords;
let values = records.map( r => model.getValue( r, "JCLASS_DISPLAY" ) ); 

apex.item( "P230_CURRENT_JNYID" ).setValue( values[0] );
position: -webkit-sticky; //Safari
position: sticky;
top: 120px;

// apply css overflow: visible; or overflow: auto; div all parent
<!--
  Hit RUN to see this project in action!
  
  This project will auto-refresh as you edit the HTML, CSS and JS. See README.md for more info (including how to disable auto-refresh and install packages).
-->

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Replit</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
 <form onsubmit="return data()"    >
   Name               <input type = "text" id= "a"> <br>
   Age <input type = "number" id= "b"> <br>
   Email <input type = "email" id= "c"> <br>
    Phone <input type = "number" id= "d"> <br>
    Password <input type = "text" id= "e"> <br>
    Re-enter Password <input type = "text" id= "f"> <br>
 <input type="submit" >
 </form>

  <script type="module" src="script.js"></script>

</body>

</html>













function data(){
let a= document.getElementById("a");
let b= document.getElementById("b");
let c= document.getElementById("c");
let d= document.getElementById("d");
let e= document.getElementById("e");
let f= document.getElementById("f");
  
  if(a==""||b==""||c==""||d==""){
    alert("all entries are mandatory");
    return false;
  }else if(isNaN(c)){
    alert("phone number must be a number");
  }else if(blur.length!=10){
    alert(" 10 digit phone no is required");
  }else if(e!=f){
   alert("passwords must be same"); 
  }
  else{
    return true;
  }
}
void DFS( int v){ 

 Thăm_Đỉnh(v);

 chuaxet[v]:= FALSE; 

 for ( u ∈ke(v) ) { 

  if (chuaxet[u] ) DFS(u); 

 } 

}
/**
 *  Custom cart redirection: / home page when cart is empty and checkout page if cart is not empty
 */

add_action('template_redirect', 'custom_cart_redirections');
function custom_cart_redirections() {
    if ( is_cart() ) {
        if ( WC()->cart->is_empty() ) {
            wp_redirect( home_url('catalog') );
            exit();
        } else {
            wp_redirect( wc_get_checkout_url() );
            exit();
        }
    }
}
// Skip the Cart Page when add to cart button
add_filter('add_to_cart_redirect', 'cw_redirect_add_to_cart');
function cw_redirect_add_to_cart() {
   global $woocommerce;
   $cw_redirect_url_checkout = $woocommerce->cart->get_checkout_url();
   return $cw_redirect_url_checkout;
}
<?php
/*
Plugin Name: Dokan Product Categories Additional Fees
Plugin URI: https://example.com
Description: Adds an "Additional Fees" field to WooCommerce product categories and displays additional fees for orders with products from multiple vendors based on the "Additional Fees" value.
Version: 1.0
Author: Your Name
Author URI: https://example.com
*/

// Exit if accessed directly
if (!defined('ABSPATH')) {
   exit;
}

function enqueue_sweetalert2() {
    wp_enqueue_style('sweetalert2', 'https://cdn.jsdelivr.net/npm/sweetalert2@11.7.3/dist/sweetalert2.min.css');
    wp_enqueue_script('sweetalert2', 'https://cdn.jsdelivr.net/npm/sweetalert2@11.7.3/dist/sweetalert2.all.min.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'enqueue_sweetalert2');

// Enqueue the JavaScript file


// Save the "Additional Fees" field value when adding/editing a product category
add_action('created_term', 'save_additional_fees_field', 10, 3);
add_action('edit_term', 'save_additional_fees_field', 10, 3);
function save_additional_fees_field($term_id, $tt_id, $taxonomy)
{
   if ('product_cat' !== $taxonomy) {
       return;
   }

   $additional_fees = isset($_POST['additional_fees']) ? sanitize_text_field($_POST['additional_fees']) : '';
   update_term_meta($term_id, 'additional_fees', $additional_fees);
}

// Add the "Additional Fees" field to the product category add/edit page
add_action('product_cat_add_form_fields', 'add_additional_fees_field');
add_action('product_cat_edit_form_fields', 'edit_additional_fees_field', 10, 2);
function add_additional_fees_field()
{
   ?>
   <div class="form-field term-additional-fees-wrap">
       <label for="additional-fees"><?php esc_html_e('Additional Fees', 'woocommerce'); ?></label>
       <input type="text" name="additional_fees" id="additional-fees" value="">
   </div>
   <?php
}

function edit_additional_fees_field($term, $taxonomy)
{
   $additional_fees = get_term_meta($term->term_id, 'additional_fees', true);
   ?>
   <tr class="form-field term-additional-fees-wrap">
       <th scope="row"><label for="additional-fees"><?php esc_html_e('Additional Fees', 'woocommerce'); ?></label></th>
       <td><input type="text" name="additional_fees" id="additional-fees" value="<?php echo esc_attr($additional_fees); ?>"></td>
   </tr>
   <?php
}

/**
* Display Additional Fees message in the cart
*/
add_action('woocommerce_cart_totals_before_order_total', 'display_additional_fees_in_cart');
function display_additional_fees_in_cart()
{
   $product_id = get_the_ID();
   $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));

   // Iterate through the categories and get the additional fees
   $additional_fees = 0;
   foreach ($product_categories as $category_id) {
       $category_additional_fees = get_term_meta($category_id, 'additional_fees', true);
       if (!empty($category_additional_fees)) {
           $additional_fees = max($additional_fees, $category_additional_fees);
       }
   }

   // Display the additional fees if they exist
   if ($additional_fees > 0) {
       echo '<div class="woocommerce-notices-wrapper">';
       echo '<ul class="woocommerce-error" role="alert">';
       echo '<li>' . esc_html__('رسوم إضافية:', 'woocommerce') . ' ' . wc_price($additional_fees) . '</li>';
       echo '</ul>';
       echo '</div>';
   }
}

/**
* Display Additional Fees message on the product page
*/
add_action('woocommerce_before_add_to_cart_button', 'display_additional_fees_message');
function display_additional_fees_message() {
    global $product;

    // Get the product categories
    $product_categories = wp_get_post_terms($product->get_id(), 'product_cat', array('fields' => 'ids'));

    // Iterate through the categories and get the additional fees
    $additional_fees = 0;
    foreach ($product_categories as $category_id) {
        $category_additional_fees = get_term_meta($category_id, 'additional_fees', true);
        if (!empty($category_additional_fees)) {
            $additional_fees = max($additional_fees, $category_additional_fees);
        }
    }

    // Get the vendor ID for this product
    $vendor_id = get_post_field('post_author', $product->get_id());

    // Check if there are products from other vendors in the cart
    $other_vendors = false;
    foreach (WC()->cart->get_cart() as $cart_item) {
        $product_id = $cart_item['product_id'];
        $item_vendor_id = get_post_field('post_author', $product_id);
        if ($item_vendor_id != $vendor_id) {
            $other_vendors = true;
            break;
        }
    }

    // Display the message if additional fees exist and there are products from other vendors in the cart
    if ($additional_fees > 0 && $other_vendors) {
        ?>
        <script type="text/javascript">
        (function($) {
            $('form.cart').on('submit', function(e) {
                e.preventDefault();
                Swal.fire({
                    title: '<?php esc_html_e('رسوم إضافية', 'woocommerce'); ?>',
                    html: '<?php echo sprintf(esc_html__('سيتم تطبيق رسوم إضافية بقيمة %s على طلبك.', 'woocommerce'), wc_price($additional_fees)); ?>',
                    icon: 'warning',
                    confirmButtonText: '<?php esc_html_e('موافق', 'woocommerce'); ?>'
                }).then((result) => {
                    if (result.isConfirmed) {
                        $(this).unbind('submit').submit();
                    }
                });
            });
        })(jQuery);
        </script>
        <?php
    }
}

add_action('wp_ajax_display_multi_vendor_warning', 'display_multi_vendor_warning');
add_action('wp_ajax_nopriv_display_multi_vendor_warning', 'display_multi_vendor_warning');
function display_multi_vendor_warning() {
    $product_ids = $_POST['product_ids'];

    $vendors = array();
    foreach ($product_ids as $product_id) {
        $vendor_id = get_post_field('post_author', $product_id);
        $vendors[$vendor_id] = true;
    }

    if (count($vendors) > 1) {
        $response = array(
            'success' => true,
            'message' => esc_html__('سلة التسوق الخاصة بك تحتوي على منتجات من عدة بائعين. قد تطبق رسوم إضافية.', 'woocommerce')
        );
    } else {
        $response = array(
            'success' => false,
            'message' => ''
        );
    }

    wp_send_json($response);
}

/**
 * Display a warning message if cart contains products from multiple vendors
 */
function add_additional_fees_script_to_footer() {
    ?>
    <script type="text/javascript">
    (function($) {
        var $woocommerce_div = $('div.woocommerce');

        function check_and_display_multi_vendor_warning() {
            var product_ids = [];
            $('div.woocommerce-cart-form__cart-item').each(function() {
                var $product_id = $(this).data('product_id');
                product_ids.push($product_id);
            });

            $.ajax({
                type: 'POST',
                url: '<?php echo admin_url('admin-ajax.php'); ?>',
                data: {
                    action: 'display_multi_vendor_warning',
                    product_ids: product_ids
                },
                success: function(response) {
                    if (response.success) {
                        $message = response.message;
                        if ($message) {
                            $woocommerce_div.prepend('<div class="woocommerce-notices-wrapper">' +
                                '<ul class="woocommerce-error" role="alert">' +
                                '<li>' + $message + '</li>' +
                                '</ul>' +
                                '</div>');
                        } else {
                            $woocommerce_div.find('.woocommerce-notices-wrapper').remove();
                        }
                    }
                },
                error: function() {
                    console.log('Error displaying multi-vendor warning');
                }
            });
        }

        $(document).ready(function() {
            check_and_display_multi_vendor_warning();
        });

        $woocommerce_div.on('updated_wc_div', function() {
            check_and_display_multi_vendor_warning();
        });
    })(jQuery);
    </script>
    <?php
}
add_action('wp_footer', 'add_additional_fees_script_to_footer');
//=========================================================================================================
function calculate_additional_fees() {
    $additional_fees = 0;

    foreach (WC()->cart->get_cart() as $cart_item) {
        $product_id = $cart_item['product_id'];
        $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));

        foreach ($product_categories as $category_id) {
            $category_additional_fees = get_term_meta($category_id, 'additional_fees', true);
            if (!empty($category_additional_fees)) {
                $additional_fees = max($additional_fees, $category_additional_fees);
            }
        }
    }

    return $additional_fees;
}
add_action('woocommerce_cart_calculate_fees', 'add_additional_fees_to_cart_total');
function add_additional_fees_to_cart_total(WC_Cart $cart) {
    $additional_fees = calculate_additional_fees();

    if ($additional_fees > 0) {
        $cart->add_fee(__('رسوم إضافية', 'woocommerce'), $additional_fees);
    }
}

//=================================================================================
/**
 * Display additional fees in order details
 */
add_action('woocommerce_admin_order_data_after_order_details', 'display_additional_fees_order_meta');
function display_additional_fees_order_meta($order) {
    $additional_fees = get_post_meta($order->get_id(), 'additional_fees', true);

    if (!empty($additional_fees)) {
        ?>
        <div class="order_data_column">
            <h4><?php esc_html_e('Additional Fees', 'woocommerce'); ?></h4>
            <p><?php echo wc_price($additional_fees); ?></p>
        </div>
        <?php
    }
}

/**
 * Save additional fees meta for the order
 */
add_action('woocommerce_checkout_create_order_line_item', 'save_additional_fees_order_meta', 10, 4);
function save_additional_fees_order_meta($item, $cart_item_key, $values, $order) {
    $additional_fees = calculate_additional_fees();

    if ($additional_fees > 0) {
        $order->update_meta_data('additional_fees', $additional_fees);
    }
}
star

Tue May 07 2024 22:38:42 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Tue May 07 2024 22:26:28 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Tue May 07 2024 17:09:13 GMT+0000 (Coordinated Universal Time)

@agung #aws #ec2

star

Tue May 07 2024 16:13:39 GMT+0000 (Coordinated Universal Time)

@CarlosR

star

Tue May 07 2024 15:17:01 GMT+0000 (Coordinated Universal Time)

@vedanti

star

Tue May 07 2024 15:16:08 GMT+0000 (Coordinated Universal Time)

@vedanti

star

Tue May 07 2024 15:14:59 GMT+0000 (Coordinated Universal Time)

@vedanti

star

Tue May 07 2024 15:14:14 GMT+0000 (Coordinated Universal Time)

@vedanti

star

Tue May 07 2024 15:13:22 GMT+0000 (Coordinated Universal Time)

@vedanti

star

Tue May 07 2024 13:21:59 GMT+0000 (Coordinated Universal Time)

@login123

star

Tue May 07 2024 12:37:06 GMT+0000 (Coordinated Universal Time)

@login123

star

Tue May 07 2024 11:20:40 GMT+0000 (Coordinated Universal Time)

@zeinrahmad99

star

Tue May 07 2024 10:43:01 GMT+0000 (Coordinated Universal Time)

@divyasoni23 #html #php

star

Tue May 07 2024 08:03:14 GMT+0000 (Coordinated Universal Time) https://chatgpt.com/c/f7aca05f-2e9f-4596-ba4e-ae1b91e73435

@jass855

star

Tue May 07 2024 07:59:26 GMT+0000 (Coordinated Universal Time)

@jass855 #python

star

Tue May 07 2024 07:52:36 GMT+0000 (Coordinated Universal Time) https://cloud.google.com/python/docs/reference/aiplatform/latest/index.html

@rosa

star

Tue May 07 2024 07:34:17 GMT+0000 (Coordinated Universal Time) https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal

@rosa #python

star

Tue May 07 2024 07:32:25 GMT+0000 (Coordinated Universal Time)

@Yous

star

Tue May 07 2024 06:04:55 GMT+0000 (Coordinated Universal Time)

@proxylabs

star

Tue May 07 2024 06:03:34 GMT+0000 (Coordinated Universal Time)

@proxylabs

star

Tue May 07 2024 05:58:56 GMT+0000 (Coordinated Universal Time)

@proxylabs

star

Tue May 07 2024 05:34:17 GMT+0000 (Coordinated Universal Time)

@proxylabs

star

Mon May 06 2024 22:28:51 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Mon May 06 2024 22:04:55 GMT+0000 (Coordinated Universal Time) https://www.thespreadsheetguru.com/loop-open-workbooks-and-modify/

@acassell

star

Mon May 06 2024 21:33:34 GMT+0000 (Coordinated Universal Time) https://www.experts-exchange.com/articles/1457/Automate-Exporting-all-Components-in-an-Excel-Project.html

@acassell

star

Mon May 06 2024 21:31:28 GMT+0000 (Coordinated Universal Time) https://www.devhut.net/vba-fso-files-folders-drives-and-more/

@acassell

star

Mon May 06 2024 21:24:33 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-us/outlook/troubleshoot/development/vba-macro-that-uses-data-from-word-and-excel-to-send-messages?source

@acassell

star

Mon May 06 2024 21:22:08 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-us/outlook/troubleshoot/development/vba-macro-that-uses-data-from-word-and-excel-to-send-messages?source

@acassell

star

Mon May 06 2024 21:20:52 GMT+0000 (Coordinated Universal Time) https://wellsr.com/vba/2018/excel/list-files-in-folder-and-subfolders-with-vba-filesystemobject/

@acassell

star

Mon May 06 2024 21:18:48 GMT+0000 (Coordinated Universal Time) https://wellsr.com/vba/2019/excel/list-all-environment-variables-with-vba-environ/

@acassell

star

Mon May 06 2024 21:04:29 GMT+0000 (Coordinated Universal Time) https://chandoo.org/forum/threads/macro-to-extract-text-from-word-doc.43933/

@acassell

star

Mon May 06 2024 20:55:14 GMT+0000 (Coordinated Universal Time) https://chandoo.org/forum/threads/macro-to-extract-text-from-word-doc.43933/

@acassell

star

Mon May 06 2024 20:53:39 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/drives-property

@acassell

star

Mon May 06 2024 20:51:19 GMT+0000 (Coordinated Universal Time) https://wellsr.com/vba/2019/excel/vba-udf-to-enhance-excel-cell-and-info-functions/

@acassell

star

Mon May 06 2024 20:49:02 GMT+0000 (Coordinated Universal Time) https://chandoo.org/forum/threads/macro-to-extract-text-from-word-doc.43933/

@acassell

star

Mon May 06 2024 20:26:40 GMT+0000 (Coordinated Universal Time)

@taharjt

star

Mon May 06 2024 18:58:29 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=simV5Ga4Xr4

@2late

star

Mon May 06 2024 14:15:53 GMT+0000 (Coordinated Universal Time) https://community.dynamics.com/forums/thread/details/?threadid

@obaidullahjadun

star

Mon May 06 2024 11:26:20 GMT+0000 (Coordinated Universal Time)

@Reemhel #sql

star

Mon May 06 2024 10:20:53 GMT+0000 (Coordinated Universal Time)

@divyasoni23 #css

star

Mon May 06 2024 10:04:14 GMT+0000 (Coordinated Universal Time)

@prakharleet

star

Mon May 06 2024 09:45:31 GMT+0000 (Coordinated Universal Time) https://www.scaler.com/topics/flutter-stripe/

@hey123

star

Mon May 06 2024 09:09:49 GMT+0000 (Coordinated Universal Time) https://expressmagazine.net/development/4009/thuat-toan-ve-tim-kiem-theo-chieu-sau-dfs-bang-ngon-ngu-cc

@haiquydo2311

star

Mon May 06 2024 08:24:47 GMT+0000 (Coordinated Universal Time)

@mastaklance

star

Mon May 06 2024 08:23:41 GMT+0000 (Coordinated Universal Time)

@mastaklance

star

Mon May 06 2024 08:13:33 GMT+0000 (Coordinated Universal Time)

@mebean #php

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension