Mac not compiling into Windows

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Mac not compiling into Windows

Post by RobertTeeter » Tue May 25, 2021 4:03 pm

A program that worked for 6 months developed in Mac, then compiled into Windows worked for 6 months. Now the message path works in Mac but fails in Windows. Specifically, a read function, in main stack script, called from many locations does not work. Calls in the stack script work, calls from below, in other words. card or card object level do not work. If function is repeated as a private function on the card, the read works again. ONLY in windows. Still works properly in Mac. Advice please.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Mac not compiling into Windows

Post by jacque » Wed May 26, 2021 6:47 pm

Do you mean the original app stopped working suddenly, or did you recompile the app before it failed? A sudden error like that on an existing app doesn't make sense.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Thu May 27, 2021 1:17 am

This is 2nd response to Jacque, 1st at 15:45 EDT did not post.
Mac app and Windows exe version 1, delivered to grandsons for Christmas. Written in LC 9 . 6 . 2 RC4. Worked great. Program is to play musical tracks recorded on reel tape in the 1950s, and 60s. Converted to cassettes 2 sides 30 minutes each. Track identification is ST = StartTime. Program lists 1788 tracks on 134 "Collections", 246 "Albums".

Version 2 in development to add functionality, specifically, for Windows .exe to add more collections, albums and tracks. Debugging and compiling working great until about a week ago. All of the adding functions were working. So I decided to make a shortcut to the 1788 tracks (on card 5) by adding a pulldown menu (A to Z) to get near to a desired track. On this card (5) there is a menu with "Top, Update, Quit" choices. Update script is in the pulldown menu button. Top and Quit are pass menuPick. Works. AtoZ Selector menuPick message goes straight to stack script, and does not allow the selection function at the button OR card level.

While debugging this anomaly, the stack script function "ReadAFile" ceased to function. Copying the "ReadAFile" function to card 1 (InitialConditions) as a private function works in both Mac and Windows. However this screws everything below stack script that expects messages to get to stack script.

So my first question is do I have a bug, a feature or somehow operator error?
Second question - should I download 9 . 6 . 2 for Windows and debug on my Windows laptop? If so, will the "Music 2 .livecode" transfer to Windows? I have already been through text reports and Mac/Windows font differences. Program currently encodes and decodes all txt date to "UTF-8". I have updated from RC4, to 5 to 6 to final 9 . 6 . 2 on the Mac Mini M1 running BigSur 11 . 3 . 1 .

FYI -- I started programming in HyperCard, then Revolution, now LiveCode. I remember seeing JLG on the Hypercard forums.

Bob in Florida

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Mac not compiling into Windows

Post by jacque » Thu May 27, 2021 5:25 pm

That was a little hard to follow but if I understand it right then it sounds like a normal message path problem. A handler in the stack script won't know about handlers or objects on the card unless you specifically tell it where those are. Usually that means sending a message to the card or control if that's where the handler is.

It's hard to say how to fix it without seeing the readafile handler or the one that does the selections, but look for places where you expect a card or button reference and use a more specific identifier, maybe like:

Code: Select all

send <handler name > to this card 
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Thu May 27, 2021 8:16 pm

I hope the script snippets below explain my problem. Again it started with menuPick on the second pulldown menu on card 5 going directly to the stack script. Has morphed into a main function call (fReadFile) not working in the compiled Windows. I still check the Mac standalone app (which works) before sneaker-netting a USB stick over to the HP laptop. fReadFile not working breaks too many things. fReadFile has been in version 1 and working for over 8 months -- until mid-May

Note 1 -- due to this forum post not liking number . number -- all number . numbers have been replaced with number-number.

Note 2 - I believe in comments

In Stack script
function fReadFile fileToRead # 0-19
# Called by:
# openStack - 0-1
# doCheckMusicFilePath - 1-0-2
# doCheckPlayerTimeScale - 1-0-3
# doCreateAlbum1 - 7-0-3
# doCreateAlbum2 - 8-0-3
# doCreateAlbum3 - 9-0-3
# doFixSTNum - 1-0-4
# doGetAlbum_I_Data - 1-0-5
# doPDFReport2 - 3-2-4
# doReadFileAlbum - 0-10
# doReadFileMP3 - 0-11
# doReadFileText - 0-12
# doReadFileTitle - 0-13
# doUpdate - 5-0-2
# doUpdatePlayerFilePath12 - 1-0-6
# doUpdatePlayerFilePath3 - 1-0-7
# openCard - 6-0-1
open file fileToRead for text read
read from file fileToRead until EOF
close file fileToRead
return textDecode(it,"UTF-8")
end fReadFile

first subroutine in openCard message in card script 1 --Initial Conditions

on doCheckMusicFilePath # - 1-0-2
# Called by:
# openCard — 1-0-1
# Calls:
# doUpdateFilePath - 1-0-6
put defaultFolder into tFilepath
put 0 into i
repeat forever
add 1 to i
put the dgDataOfLine of group "AlbumsData" of card "Albums Alphabetical" \
into tTestAlbumName
put tTestAlbumName[AlbumTitle] into tTestFilePath
put "/Music-Data/Album-Data/" & tTestFilePath & "/MP3Filename-txt" after tFilePath # dot replaced with -
if there is not a file tfilepath then next repeat
else
put fReadFile(tFilePath) into tPlayerFilePath # ------------function call not working in compiled Windows
exit repeat
end if
end repeat
set itemDelimiter to slash
------ balance deleted

I seem to be losing message paths when compiled into Windows.

suffix numbers within scripts
0-stack script
1-Card-InitialConditions
2-Card-Top
3-Card-Collections Alpabetical
4-Card-Albums Alphabetical
5-Card-Titles or Artist Alphabetical
6-Card-CollectionsTemplate
7-Card-AlbumTemplate1
8-Card-AlbumTemplate2
9-Card-AlbumTemplate3


Bob

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac not compiling into Windows

Post by Klaus » Thu May 27, 2021 9:02 pm

Hi Bob,

something is missing here -> the line number!

Code: Select all

...
## put the dgDataOfLine of group "AlbumsData" of card "Albums Alphabetical" into tTestAlbumName
put the dgDataOfLine[the line number here!] of group "AlbumsData" of card "Albums Alphabetical" into tTestAlbumName
...

Code: Select all

...
put defaultFolder into tFilepath
...
And are you sure -> the defaultfolder is really the folder you exspect?


Best

Klaus

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Thu May 27, 2021 10:48 pm

1. Yes the defaultFolder is what I expect as card 1 stays keeps track of where the app is in setting initial conditions.

2. The sample was missing {i} after dgDataOf Line -- but it was there on Apr 17. However this line failed because the stack script failed to load the dataGrid of card 5 due to the function fReadFile failure, Current debugging app now reads the disk again LOCALLY and selects line i.

message path ???? card subroutine calls a read file function at the stack level --FAILS -- but only in compiled Windows.
Current debugging script for this subroutine reads as of 24 May:

on doCheckMusicFilePath # - 1-0-2
# Called by:
# openCard — 1-0-1
# Calls:
# doUpdateFilePath - 1-0-6
put defaultFolder into tFilepath
put 0 into i
--answer "line 64 - just before repeat forwver"
repeat 1 times # -- was forever/
add 1 to i
-- answer "line 67 - i = " & i #------------char before i is ampersand on Mac ---- Is this the source of the problem
put tFilePath & slash & "Music-Data/Top-Data/AlbumsData. txt" into tFileToRead
--answer "Line 69 - tFileToRead is: " & tFileToRead
-- put fReadFile(tFileToRead) into tTestAlbumName -------------original version

open file tfileToRead for text read --------------------------moving read file function to subroutine in card 1
--answer "line 73 - open file result is : " & the result
read from file tfileToRead until EOF
put it into taaTemp
answer "Line 75 - taaTemp is : " & taaTemp
--answer "Line 76 - read result is : " & the result
close file fileToRead
--answer "Line 79 - close file result is : " & the result
put textDecode(taaTemp,"UTF-8") into tTestAlbumName
put taaTemp into tTestAlbumName
--answer "line 82 - tTestAlbumName[AlbumTitle] is: " & line i of tTestAlbumName
put line i of tTestAlbumName into tTestFilePath
--answer "line 93 - tTestFilePath is : " & tTestFilePath with "OK"
put "/Music-Data/Album-Data/" & tTestFilePath & "/MP3Filename. txt" after tFilePath
--answer "Line 95 - MP3 file path is : " & tFilePath
if there is not a file tFilepath then
--answer "Line 88 - not a filepath "
next repeat
else

balance deleted

I have been using answers in order to determine where the failure occurs -- as you can see above --- this works BUT the read file function is now direct inline and NOT a function call to the stack. This is where I asked for help. Answers are now -- because I located the problem.

Should I download a new copy of 9 6 2 and replace my existing Mac copy?
Should I download a new copy of 9 6 2 and put it on the Windows laptop?

I think everything is in UTF-8. Also beginning to think livecode is written in Windows and compiled into Mac. Do I have a cross platform font problem? Fought that problem earlier in reports and umlauts, acute and grave accents. Fixed by removing them, also saving with text encode and decode to UTF-8.

Bob -- remaining frustrated but very appreciative of the forum help.

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Thu May 27, 2021 11:23 pm

Addendum to previous post -- & glyph displays differently in this screen but displays as the expected ampersand glyph after posting. I wish Apple and Microsoft played with the same IDENTICAL fonts. !!!

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac not compiling into Windows

Post by Klaus » Fri May 28, 2021 10:40 am

Hi Robert,

please use the CODE tags in the tool bar above this field after you have pasted your code.
That way the formatting will be preserved.

Hm, everything looks OK, but we do not know what is in -> tTestFilePath in the end.
Sounds like that is the culprit.

Hint:
You can use the shorter URL syntax for reading in files if you like to save some typing:

Code: Select all

...
put tFilePath & "/Music-Data/Top-Data/AlbumsData.txt" into tFileToRead

# LOOOOOONG "read from file" syntax:
# open file tfileToRead for text read --------------------------moving read file function to subroutine in card 1
# read from file tfileToRead until EOF
# put it into taaTemp
# close file fileToRead

# Now the URL one-liner:
put url("file:" & tfileToRead) into taaTemp
...
Even the SAME font (TTF) looks different on Mac and Windows!
That is not the fault of the font but of the text handling on the different platforms.


Best

Klaus

P.S.
When you have seven postings, you can then also post links (the thingie with the dots :-) ) images etc.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Mac not compiling into Windows

Post by AxWald » Fri May 28, 2021 11:23 am

Hi,
(just see Klaus was faster. I'll post my stuff anyways.)

a few hints:

1.) If you compose a post, look at the icons above your text input field: "</>" will wrap the selected text in "code tags":

Code: Select all

   it will look like this then ;-)
Much more easy to read, and comprehend. Thus much more easy to help.

2.) Use "the defaultFolder" (carefully!) when getting "the Files/ Folders". Else don't do it - too easy to mix things up this way! Use "specialFolderPath("resources")" (here is your stack) and "specialFolderPath("documents")" (here your docs shall reside), and if you are as lazy as me, throw both of these into a global at startUp with an added slash, for further reference:

Code: Select all

   global gPathE, gPathD

   on preOpenStack
      put specialFolderPath("resources") & slash into gPathE  --  E -> Engine = mainstack/ StandAlone, better assume readOnly
      put specialFolderPath("documents") & slash into gPathD  --  D -> Docs = you always have write access here
      --  whatever else you need
   end preOpenStack
3.) Forget "open file tfileToRead for text read" etc. if you don't really need to use it, for instance for reading a line at a time. Use:

Code: Select all

   put URL ("binfile:" & gPathD & "Music-Data/Top-Data/AlbumsData. txt" into myData  --  Or:
   put myData into URL ("binfile:" & gPathD & "Music-Data/Top-Data/AlbumsData. txt"
instead. Much shorter, fewer opportunities to mix something up (leaving files open ...).
Use protocol "file:" with care - only if you want CR/LFs & charsets converted.

4.) Handlers that are called from anywhere in a stack belong into the stack script.
Handlers that are card specific belong in the card script.
If you have handlers in a stack script that you want to use from other stacks, "start using" this stack!

5.) I see you're looking if a folder for a file exists. Why not just:

Code: Select all

   get URL ("binFile:" & myFile)  --  the desired filePath
   if the result is not empty then
      put myFile & CR & "doesn't seem to exist!"
   else
      put it
   end if
You may also use a function to determine it:

Code: Select all

function existsThis aPath
   /* Feed it a full path to a file or a folder, and see if it exists.
   Folders MUST have a trailing slash!
   Reurns "true" or "false"   */
   if char -1 of aPath is slash then  --  determine if file or folder
      put true into isAFolder
      delete char -1 of aPath         --  remove slash
   else
      put false into isAFolder
   end if
   
   put the defaultFolder into myOldDF      --  here it makes sense
   set itemdel to slash
   put item 1 to -2 of aPath into myPath   --  extract path
   set the defaultFolder to myPath
   if isAFolder then
      get the folders
   else
      get the files
   end if
   set the defaultFolder to myOldDF       --   IMPORTANT! Reset defaultFolder
   if item -1 of aPath is among the lines of it then  --  compare whole lines
      return true
   else
      return false
   end if
end existsThis
6.) You may happily ignore the fonts. They don't change the data, only how it's displayed. The "&" shows fine here (on Win).

7.) But I see you do a textDecode(taaTemp,"UTF-8") - you know that this only yields a correct result if you have read an UTF-8 file in binary form (get URL ("binFile:" & myFile))?
If it was read as "file:", or not as "open file myFile for binary read" you'll get garbage!

OK. Maybe there's something that will help you. Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Fri May 28, 2021 3:45 pm

Thanks to Klaus and Axworld for their replies, especially helpful on the code marking suggestion.

1 - Files being read were created by this program and saved as UTF-8 -- that was part of my cross platform trying to save umlauts and other accent marks. This is not the issue.[/list]

2 - My issue is message path. "fReadFile" is in stack script and is called from many lower points. For 8 months this worked in the Mac Development mode, and when compiled into a Mac App and a Windows EXE. However, about 2 weeks ago the message path failed, BUT only in the Windows Exe. My post 27 May 6:23 pm shows ny troubleshooting where I moved "fReadFile" down to the subroutine as inline code -- NOT code called from the stack. This works in Mac Development, Mac App, and Windows EXE. Therefore my conclusion is that message path is BROKEN in Windows compiler.[/list]

3 - In response to Klaus 2 -- All of my files and data including the 1. 2GB of music are in the same folder -- which becomes the default folder.[/list]

4 - Klaus 3 - I read at the entire file as I repeat loop for a specific line.

5 - Klaus 4 -- see my comment 2 above

6 - Klaus 5 - I am new to functions, but have 4 already. Will consider this in next update.

7 - Klaus 6 - Hoping to be able to ignore fonts -- I am using Verdana for both screen and reports.

8 - Klaus 7 - File was encoded UTF-8 and therefore decoded UTF-8. Again text has been working for 8 months.

9 - Please comment on message path problem -- bug, feature or operator error

Bob in Florida

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Mac not compiling into Windows

Post by Klaus » Fri May 28, 2021 4:00 pm

Hi Robert,
RobertTeeter wrote:
Fri May 28, 2021 3:45 pm
2 - My issue is message path. "fReadFile" is in stack script and is called from many lower points. For 8 months this worked in the Mac Development mode, and when compiled into a Mac App and a Windows EXE. However, about 2 weeks ago the message path failed, BUT only in the Windows Exe. My post 27 May 6:23 pm shows ny troubleshooting where I moved "fReadFile" down to the subroutine as inline code -- NOT code called from the stack. This works in Mac Development, Mac App, and Windows EXE. Therefore my conclusion is that message path is BROKEN in Windows compiler.
as I wrote earlier:
Hm, everything looks OK, but we do not know what is in -> tTestFilePath in the end.
Sounds like that is the culprit.
RobertTeeter wrote:
Fri May 28, 2021 3:45 pm
4 - Klaus 3 I read at the entire file as I repeat loop for a specific line.
And that is what my URL one-liner does, it reads the complete file into a variable or field!
RobertTeeter wrote:
Fri May 28, 2021 3:45 pm
5 - Klaus 4 -- see my comment 2 above
See above, we cannot tell you without konwing what is in your filepath in the end!?
RobertTeeter wrote:
Fri May 28, 2021 3:45 pm
6 - Klaus 5 - I am new to functions, but have 4 already. Will consider this in next update.
I did not write anything about functions. :-)


Best

Klaus

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Fri May 28, 2021 6:39 pm

Hi Klaus,
See above, we cannot tell you without konwing what is in your filepath in the end!?
1 - What should be in the file path at the end of that script snippet is "albumName/mp3Filepath . txt" which for i = 1 in my music album list is "Achtung! Hier Spielt Anton Karas". That txt file then gives me the correct file path to the music file. Later script verifies the time scale of the player and corrects MP3Filepath, if necessary, stored in another data file. Because the MP3 Filepath is coded into the player at time of play the entire path is required. There might be a simpler way -- but I am an 81 year-old programmer and programming is not my day job. The original original Music program was written in Hypercard and never intended to be cross platform. Livecode broke the Hypercard/Revolution player. So I programmed a version 1 for grandkids as read only Windows for Christmas. It works. Version 2 adds the capability to add collections, albums and tracks, without having to go into the data files with NotePad or TextEdit. Both of which I have done in the development phase.

2 - The function "fReadFile" does that in the Mac Development environment, compiled and run on a Mac, but fails when compiled to Windows. My second code example showed an inline call using "tTestFilePath". This works -- however Windows fails at the next "fReadFile" call in that subroutine. MESSAGE PATH.

3 - Also the folder "Music2" contains the following files:
Music_Files --- 247 albums --- 1 . 2 GB of music
Music-Data ---- contains
Top-Data --- contains:
TitlesArtist . txt ----- 1788 lines with track num, title, artist, start time as a number, which album
TimeScale . txt -----player timescale to check on different platforms
Statistics . txt ----- data about how many collections, albums and tracks
CollectionSelect . txt ----- A list of artists/collections -- 134
AlbumsData . txt ---- a list of albums -- 247
Collection-Data --- to get from artist to album
Album-Data -- what is displayed and played -- references to the Music_Files
Music2 . app ----- used on the Mac
Music2 . exe ----- sneaker net to Windows laptop on USB stick
revpdfprinter . dll -- same as above -- needed for reports in Windows.

4 - At this point everything in Windows plays from 1 folder. Have not tried to generalize specific windows locations , which is why my default folder calls work.

p s -- how do you get the quote to show name and up arrow ?

Bob in Florida

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Mac not compiling into Windows

Post by FourthWorld » Fri May 28, 2021 7:34 pm

RobertTeeter wrote:
Fri May 28, 2021 6:39 pm
The function "fReadFile" does that in the Mac Development environment, compiled and run on a Mac, but fails when compiled to Windows.
Does it also fail when testing in the IDE on Windows?

It's a good habit to include error-checking with all I/O. In addition to checking "the result" to know if an error occurred, you'll also want to query the sysError function to find out the specific error code the OS is reporting to us, e.g.:

Code: Select all

put URL ("binfile:" & gPathD & "Music-Data/Top-Data/AlbumsData. txt" into myData
if the result is not empty then
   answer "Couldn't read file &quote& pPathD &quote&" ("& sysError() &")"
   exit to top
end if
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

RobertTeeter
Posts: 11
Joined: Tue May 25, 2021 3:56 pm

Re: Mac not compiling into Windows

Post by RobertTeeter » Fri May 28, 2021 8:08 pm

Richard --

I don't have and IDE for Windows. I develop on a Mac Mini M1. Only my Windows 10 exe is failing.

How do I get the IDE for Windows ?
Can I sneaker net the Mac " dot livecode file from the Mac to the laptop ?

Bob

Post Reply

Return to “Windows”