Author Topic: Date Picker using PowerShell  (Read 2566 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Date Picker using PowerShell
« on: May 08, 2020, 04:04:33 pm »
So I'm starting to work on a date picker that would be called using
Code: QB64: [Select]
  1. a = _SHELLHIDE("PowerShell -ExecutionPolicy Bypass " + CHR$(34) + "&'" + _STARTDIR$ + "\GetNewDate.ps1';exit $LASTEXITCODE" + CHR$(34)
The PowerShell script I'm editing would send the date that the user picked back in the MMDDYYYY format and use it as an Int32 to pass it back as the $LASTEXITCODE so that it can be stored in "a". Then you could convert it to a string and read it as a date using your own date parsing functions. For instance, today's date could come back to QB64 as:
Code: QB64: [Select]
  1. SHELL$ = "PowerShell -ExecutionPolicy Bypass " + CHR$(34) + "&'" + _STARTDIR$ + "\GetNewDate.ps1';exit $LASTEXITCODE" + CHR$(34)
  2. a = SHELL(SHELL$)
  3. olddate$ = DATE$
  4. olddate$ = Remove(olddate$, "-")
  5. old = VAL(olddate$)
  6. olddate$ = LTRIM$(STR$(old))
  7.     CASE 7
  8.         newdate$ = LTRIM$(STR$(a))
  9.         month$ = "0" + MID$(newdate$, 1, 1)
  10.         day$ = MID$(newdate$, 2, 2)
  11.         year$ = MID$(newdate$, 4, 4)
  12.     CASE 8
  13.         newdate$ = LTRIM$(STR$(a))
  14.         month$ = MID$(newdate$, 1, 2)
  15.         day$ = MID$(newdate$, 3, 2)
  16.         year$ = MID$(newdate$, 5, 4)
  17. newdate$ = month$ + "-" + day$ + "-" + year$
  18. PRINT newdate$
  19. '$INCLUDE:'Remove.BM'
This would prevent you from having to output the date to a text file and read it back in.
:)
  [ You are not allowed to view this attachment ]  
  [ You are not allowed to view this attachment ]  
« Last Edit: May 08, 2020, 04:05:48 pm by SpriggsySpriggs »
Shuwatch!